Skip to contentSkip to conversation

net/ifc: fix unchecked return value

PATCH Applied Xiao Wang 3 participants 3 messages Nov 26, 2019 Network drivers

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

PATCH 1/1 net/ifc: fix unchecked return value

It's possible that we fail to get the IOMMU group of ifcvf device, this patch adds a check on the return value.

Coverity issue: 349894

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
---
 drivers/net/ifc/ifcvf_vdpa.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +6 -2
index 9c562def0..da4667ba5 100644
@@ -136,15 +136,19 @@ ifcvf_vfio_setup(struct ifcvf_internal *internal)
 	struct rte_pci_device *dev = internal->pdev;
 	char devname[RTE_DEV_NAME_MAX_LEN] = {0};
 	int iommu_group_num;
-	int i;
+	int i, ret;
 
 	internal->vfio_dev_fd = -1;
 	internal->vfio_group_fd = -1;
 	internal->vfio_container_fd = -1;
 
 	rte_pci_device_name(&dev->addr, devname, RTE_DEV_NAME_MAX_LEN);
-	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,
+	ret = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,
 			&iommu_group_num);
+	if (ret <= 0) {
+		DRV_LOG(ERR, "%s failed to get IOMMU group", devname);
+		return -1;
+	}
 
 	internal->vfio_container_fd = rte_vfio_container_create();
 	if (internal->vfio_container_fd < 0)
Signature · 1 line
2.15.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines · Xiao Wang

It's possible that we fail to get the IOMMU group of ifcvf device, this patch adds a check on the return value.

Coverity issue: 349894

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

---
drivers/net/ifc/ifcvf_vdpa.c | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +6 -2
index 9c562def0..da4667ba5 100644
@@ -136,15 +136,19 @@ ifcvf_vfio_setup(struct ifcvf_internal *internal)
 	struct rte_pci_device *dev = internal->pdev;
 	char devname[RTE_DEV_NAME_MAX_LEN] = {0};
 	int iommu_group_num;
-	int i;
+	int i, ret;
 
 	internal->vfio_dev_fd = -1;
 	internal->vfio_group_fd = -1;
 	internal->vfio_container_fd = -1;
 
 	rte_pci_device_name(&dev->addr, devname, RTE_DEV_NAME_MAX_LEN);
-	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,
+	ret = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,
 			&iommu_group_num);
+	if (ret <= 0) {
+		DRV_LOG(ERR, "%s failed to get IOMMU group", devname);
+		return -1;
+	}
 
 	internal->vfio_container_fd = rte_vfio_container_create();
 	if (internal->vfio_container_fd < 0)
Signature · 1 line
2.15.1
Applied
#2 lore raw
Quoted 37 lines · Ye Xiaolong
Quoted 36 lines · Xiao Wang

It's possible that we fail to get the IOMMU group of ifcvf device, this patch adds a check on the return value.

Coverity issue: 349894

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

---
drivers/net/ifc/ifcvf_vdpa.c | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +6 -2
index 9c562def0..da4667ba5 100644
@@ -136,15 +136,19 @@ ifcvf_vfio_setup(struct ifcvf_internal *internal)
 	struct rte_pci_device *dev = internal->pdev;
 	char devname[RTE_DEV_NAME_MAX_LEN] = {0};
 	int iommu_group_num;
-	int i;
+	int i, ret;
 
 	internal->vfio_dev_fd = -1;
 	internal->vfio_group_fd = -1;
 	internal->vfio_container_fd = -1;
 
 	rte_pci_device_name(&dev->addr, devname, RTE_DEV_NAME_MAX_LEN);
-	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,
+	ret = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,
 			&iommu_group_num);
+	if (ret <= 0) {
+		DRV_LOG(ERR, "%s failed to get IOMMU group", devname);
+		return -1;
+	}
 
Quoted 8 lines
Quoted 5 lines
drivers/net/ifc/ifcvf_vdpa.c +0 -0
 	internal->vfio_container_fd = rte_vfio_container_create();
 	if (internal->vfio_container_fd < 0)
Signature · 1 line
2.15.1

Applied to dpdk-next-net/master, thanks.