vdpa/ifc: check PCI config read
authorXiao Wang <xiao.w.wang@intel.com>
Tue, 9 Mar 2021 08:43:15 +0000 (16:43 +0800)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 31 Mar 2021 06:39:14 +0000 (08:39 +0200)
The return value of rte_pci_read_config should be checked.

Coverity issue: 302860
Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
Cc: stable@dpdk.org
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
drivers/vdpa/ifc/base/ifcvf.c

index 3c0b2df..721cb1d 100644 (file)
@@ -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;