mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
vp_vdpa: fix id_table array not null terminated error
commit4e39ecadf1
upstream. Allocate one extra virtio_device_id as null terminator, otherwise vdpa_mgmtdev_get_classes() may iterate multiple times and visit undefined memory. Fixes:ffbda8e9df
("vdpa/vp_vdpa : add vdpa tool support in vp_vdpa") Cc: stable@vger.kernel.org Suggested-by: Parav Pandit <parav@nvidia.com> Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com> Signed-off-by: Xiaoguang Wang <lege.wang@jaguarmicro.com> Message-Id: <20241105133518.1494-1-lege.wang@jaguarmicro.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Parav Pandit <parav@nvidia.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
15c49f91cf
commit
c4d64534d4
|
@ -591,7 +591,11 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
goto mdev_err;
|
||||
}
|
||||
|
||||
mdev_id = kzalloc(sizeof(struct virtio_device_id), GFP_KERNEL);
|
||||
/*
|
||||
* id_table should be a null terminated array, so allocate one additional
|
||||
* entry here, see vdpa_mgmtdev_get_classes().
|
||||
*/
|
||||
mdev_id = kcalloc(2, sizeof(struct virtio_device_id), GFP_KERNEL);
|
||||
if (!mdev_id) {
|
||||
err = -ENOMEM;
|
||||
goto mdev_id_err;
|
||||
|
@ -611,8 +615,8 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
goto probe_err;
|
||||
}
|
||||
|
||||
mdev_id->device = mdev->id.device;
|
||||
mdev_id->vendor = mdev->id.vendor;
|
||||
mdev_id[0].device = mdev->id.device;
|
||||
mdev_id[0].vendor = mdev->id.vendor;
|
||||
mgtdev->id_table = mdev_id;
|
||||
mgtdev->max_supported_vqs = vp_modern_get_num_queues(mdev);
|
||||
mgtdev->supported_features = vp_modern_get_features(mdev);
|
||||
|
|
Loading…
Reference in New Issue
Block a user