Unverified Commit 2487a183 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14064 vp_vdpa: fix id_table array not null terminated error

parents 6e17f5be cdfea88d
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -574,7 +574,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;
@@ -594,8 +598,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);