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.hu...@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

Reply via email to