raw/ifpga/base: check null pointer in PMCI

Do null-checking on hw->adapter in fme_pmci_init() before dereference it.

Coverity issue: 379202
Fixes: ca6eb0f7c8 ("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>
This commit is contained in:
Wei Huang 2022-06-22 23:11:30 -04:00 committed by Thomas Monjalon
parent 099da89792
commit b6e029cfa4

View 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 {