Skip to contentSkip to conversation

vdpa/ifc: check return value for PCI config read

PATCH Applied Xiao Wang 2 participants 3 messages Mar 9, 2021 – Mar 31, 2021 virtio core

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

PATCH 1/1 vdpa/ifc: check return value for PCI config read

The return value of rte_pci_read_config should be checked.

Coverity issue: 302860

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
---
 drivers/vdpa/ifc/base/ifcvf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/vdpa/ifc/base/ifcvf.c +6 -1
index 3c0b2dff66..721cb1da8a 100644
@@ -65,8 +65,13 @@ ifcvf_init_hw(struct ifcvf_hw *hw, PCI_DEV *dev)
 			hw->common_cfg = get_cap_addr(hw, &cap);
 			break;
 		case IFCVF_PCI_CAP_NOTIFY_CFG:
-			PCI_READ_CONFIG_DWORD(dev, &hw->notify_off_multiplier,
+			ret = PCI_READ_CONFIG_DWORD(dev,
+					&hw->notify_off_multiplier,
 					pos + sizeof(cap));
+			if (ret < 0) {
+				DEBUGOUT("failed to read notify_off_multiplier\n");
+				return -1;
+			}
 			hw->notify_base = get_cap_addr(hw, &cap);
 			hw->notify_region = cap.bar;
 			break;
Signature · 1 line
2.15.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines

-----Original Message-----
From: Wang, Xiao W <[email protected]>
Sent: Tuesday, March 9, 2021 4:43 PM
To: Xia, Chenbo <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; [email protected]
Subject: [PATCH] vdpa/ifc: check return value for PCI config read

The return value of rte_pci_read_config should be checked.

Coverity issue: 302860

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
---
 drivers/vdpa/ifc/base/ifcvf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/vdpa/ifc/base/ifcvf.c +6 -2
index 3c0b2dff66..721cb1da8a 100644
@@ -65,8 +65,13 @@ ifcvf_init_hw(struct ifcvf_hw *hw, PCI_DEV *dev)
 			hw->common_cfg = get_cap_addr(hw, &cap);
 			break;
 		case IFCVF_PCI_CAP_NOTIFY_CFG:
-			PCI_READ_CONFIG_DWORD(dev, &hw->notify_off_multiplier,
+			ret = PCI_READ_CONFIG_DWORD(dev,
+					&hw->notify_off_multiplier,
 					pos + sizeof(cap));
+			if (ret < 0) {
+				DEBUGOUT("failed to read notify_off_multiplier\n");
+				return -1;
+			}
 			hw->notify_base = get_cap_addr(hw, &cap);
 			hw->notify_region = cap.bar;
 			break;
--
Quoted 1 line

2.15.1

Applied
#2 lore raw
In reply to Xiao Wang
Quoted 9 lines

-----Original Message-----
From: Wang, Xiao W <[email protected]>
Sent: Tuesday, March 9, 2021 4:43 PM
To: Xia, Chenbo <[email protected]>
Cc: [email protected]; Wang, Xiao W <[email protected]>; [email protected]
Subject: [PATCH] vdpa/ifc: check return value for PCI config read

The return value of rte_pci_read_config should be checked.

Quoted 7 lines

Coverity issue: 302860

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

--
2.15.1

Applied to next-virtio/main, Thanks!