]> git.droids-corp.org - dpdk.git/commitdiff
raw/ifpga/base: check null pointer in PMCI
authorWei Huang <wei.huang@intel.com>
Thu, 23 Jun 2022 03:11:30 +0000 (23:11 -0400)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 26 Jun 2022 10:20:44 +0000 (12:20 +0200)
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>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
drivers/raw/ifpga/base/ifpga_fme.c

index 25ff819955f890e31b2c2031d254557361a10bfa..b6dd4ce58c2ba6c9284cdb05b34c63591d1e8e46 100644 (file)
@@ -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 {