vdpa/ifc: check return value for PCI config read

Message ID 20210309084315.12276-1-xiao.w.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series vdpa/ifc: check return value for PCI config read |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/travis-robot success travis build: passed
ci/github-robot success github build: passed
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Xiao Wang March 9, 2021, 8:43 a.m. UTC
  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>
---
 drivers/vdpa/ifc/base/ifcvf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Chenbo Xia March 25, 2021, 2:41 a.m. UTC | #1
> -----Original Message-----
> From: Wang, Xiao W <xiao.w.wang@intel.com>
> Sent: Tuesday, March 9, 2021 4:43 PM
> To: Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Wang, Xiao W <xiao.w.wang@intel.com>; stable@dpdk.org
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> ---
>  drivers/vdpa/ifc/base/ifcvf.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
> index 3c0b2dff66..721cb1da8a 100644
> --- a/drivers/vdpa/ifc/base/ifcvf.c
> +++ b/drivers/vdpa/ifc/base/ifcvf.c
> @@ -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;
> --
> 2.15.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Chenbo Xia March 31, 2021, 6:51 a.m. UTC | #2
> -----Original Message-----
> From: Wang, Xiao W <xiao.w.wang@intel.com>
> Sent: Tuesday, March 9, 2021 4:43 PM
> To: Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Wang, Xiao W <xiao.w.wang@intel.com>; stable@dpdk.org
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> --
> 2.15.1

Applied to next-virtio/main, Thanks!
  

Patch

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index 3c0b2dff66..721cb1da8a 100644
--- a/drivers/vdpa/ifc/base/ifcvf.c
+++ b/drivers/vdpa/ifc/base/ifcvf.c
@@ -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;