Message ID | 1655953890-26163-1-git-send-email-wei.huang@intel.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Thomas Monjalon |
Headers | show |
Series | raw/ifpga/base: check pointer before dereference | expand |
Context | Check | Description |
---|---|---|
ci/iol-abi-testing | warning | Testing issues |
ci/iol-x86_64-unit-testing | success | Testing PASS |
ci/iol-aarch64-compile-testing | success | Testing PASS |
ci/iol-intel-Performance | success | Performance Testing PASS |
ci/iol-x86_64-compile-testing | success | Testing PASS |
ci/github-robot: build | success | github build: passed |
ci/iol-intel-Functional | success | Functional Testing PASS |
ci/iol-aarch64-unit-testing | success | Testing PASS |
ci/intel-Testing | success | Testing PASS |
ci/Intel-compilation | success | Compilation OK |
ci/checkpatch | success | coding style OK |
> -----Original Message----- > From: Huang, Wei <wei.huang@intel.com> > Sent: Thursday, June 23, 2022 11:12 AM > To: dev@dpdk.org; thomas@monjalon.net; nipun.gupta@nxp.com; > hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei > <tianfei.zhang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Huang, Wei > <wei.huang@intel.com> > Subject: [PATCH] raw/ifpga/base: check pointer before dereference > > Do null-checking on hw->adapter in fme_pmci_init() before dereference it. > > Coverity issue: 379202 > Fixes: ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver") > > Signed-off-by: Wei Huang <wei.huang@intel.com> > --- > drivers/raw/ifpga/base/ifpga_fme.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/raw/ifpga/base/ifpga_fme.c > b/drivers/raw/ifpga/base/ifpga_fme.c > index 25ff819..b6dd4ce 100644 > --- a/drivers/raw/ifpga/base/ifpga_fme.c > +++ b/drivers/raw/ifpga/base/ifpga_fme.c > @@ -1591,7 +1591,7 @@ static int fme_pmci_init(struct ifpga_feature > *feature) > int ret = 0; > > hw = fme->parent; > - if (!hw) > + if (!hw || !hw->adapter) > return -ENODEV; > > mgr = hw->adapter->mgr; > @@ -1608,7 +1608,7 @@ static int fme_pmci_init(struct ifpga_feature > *feature) > > max10->type = M10_N6000; > max10->mmio = feature->addr; > - if (hw->adapter && hw->adapter->shm.ptr) { > + if (hw->adapter->shm.ptr) { > sd = (opae_share_data *)hw->adapter->shm.ptr; > max10->bmc_ops.mutex = &sd->spi_mutex; > } else { > -- > 1.8.3.1 It looks good for me. Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
Hi, > -----Original Message----- > From: Huang, Wei <wei.huang@intel.com> > Sent: Thursday, June 23, 2022 11:12 > To: dev@dpdk.org; thomas@monjalon.net; nipun.gupta@nxp.com; > hemant.agrawal@nxp.com > Cc: stable@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei > <tianfei.zhang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Huang, Wei > <wei.huang@intel.com> > Subject: [PATCH] raw/ifpga/base: check pointer before dereference > > Do null-checking on hw->adapter in fme_pmci_init() before dereference it. > > Coverity issue: 379202 > Fixes: ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver") > > Signed-off-by: Wei Huang <wei.huang@intel.com> > --- > drivers/raw/ifpga/base/ifpga_fme.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/raw/ifpga/base/ifpga_fme.c > b/drivers/raw/ifpga/base/ifpga_fme.c > index 25ff819..b6dd4ce 100644 > --- a/drivers/raw/ifpga/base/ifpga_fme.c > +++ b/drivers/raw/ifpga/base/ifpga_fme.c > @@ -1591,7 +1591,7 @@ static int fme_pmci_init(struct ifpga_feature > *feature) > int ret = 0; > > hw = fme->parent; > - if (!hw) > + if (!hw || !hw->adapter) > return -ENODEV; > > mgr = hw->adapter->mgr; > @@ -1608,7 +1608,7 @@ static int fme_pmci_init(struct ifpga_feature > *feature) > > max10->type = M10_N6000; > max10->mmio = feature->addr; > - if (hw->adapter && hw->adapter->shm.ptr) { > + if (hw->adapter->shm.ptr) { > sd = (opae_share_data *)hw->adapter->shm.ptr; > max10->bmc_ops.mutex = &sd->spi_mutex; > } else { > -- > 1.8.3.1 Acked-by: Rosen Xu <rosen.xu@intel.com>
> > Do null-checking on hw->adapter in fme_pmci_init() before dereference it. > > > > Coverity issue: 379202 > > Fixes: ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver") > > > > Signed-off-by: Wei Huang <wei.huang@intel.com> > > It looks good for me. > > Acked-by: Tianfei Zhang <tianfei.zhang@intel.com> Applied, thanks.
diff --git a/drivers/raw/ifpga/base/ifpga_fme.c b/drivers/raw/ifpga/base/ifpga_fme.c index 25ff819..b6dd4ce 100644 --- a/drivers/raw/ifpga/base/ifpga_fme.c +++ b/drivers/raw/ifpga/base/ifpga_fme.c @@ -1591,7 +1591,7 @@ static int fme_pmci_init(struct ifpga_feature *feature) int ret = 0; hw = fme->parent; - if (!hw) + if (!hw || !hw->adapter) return -ENODEV; mgr = hw->adapter->mgr; @@ -1608,7 +1608,7 @@ static int fme_pmci_init(struct ifpga_feature *feature) max10->type = M10_N6000; max10->mmio = feature->addr; - if (hw->adapter && hw->adapter->shm.ptr) { + if (hw->adapter->shm.ptr) { sd = (opae_share_data *)hw->adapter->shm.ptr; max10->bmc_ops.mutex = &sd->spi_mutex; } else {
Do null-checking on hw->adapter in fme_pmci_init() before dereference it. Coverity issue: 379202 Fixes: ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver") Signed-off-by: Wei Huang <wei.huang@intel.com> --- drivers/raw/ifpga/base/ifpga_fme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)