raw/ifpga/base: check pointer before dereference
PATCH 1/1 raw/ifpga/base: check pointer before dereference
Do null-checking on hw->adapter in fme_pmci_init() before dereference it.
Coverity issue: 379202
--- drivers/raw/ifpga/base/ifpga_fme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/raw/ifpga/base/ifpga_fme.c +2 -2
@@ -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 {
Signature · 1 line
1.8.3.1
Quoted 46 lines
-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Thursday, June 23, 2022 11:12 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; Zhang, Qi Z <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH] raw/ifpga/base: check pointer before dereferenceDo null-checking on
hw->adapterinfme_pmci_init()before dereference it.Coverity issue: 379202
Fixes ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver")Signed-off-by Wei Huang <[email protected]>--- drivers/raw/ifpga/base/ifpga_fme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ifpga/base/ifpga_fme.c +1
-1@@ -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 ;drivers/raw/ifpga/base/ifpga_fme.c +1
-1mgr = 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;
Quoted 3 lines
} else {
--
1.8.3.1
It looks good for me.
Thomas Monjalon
AppliedQuoted 10 lines
Quoted 6 lines
Do null-checking on
hw->adapterinfme_pmci_init()before dereference it.Coverity issue: 379202
Fixes ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver")Signed-off-by Wei Huang <[email protected]>It looks good for me.
Acked-by Tianfei Zhang <[email protected]>
Applied, thanks.
Hi,
Quoted 44 lines
-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Thursday, June 23, 2022 11:12
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; Zhang, Qi Z <[email protected]>; Huang, Wei <[email protected]>
Subject: [PATCH] raw/ifpga/base: check pointer before dereferenceDo null-checking on
hw->adapterinfme_pmci_init()before dereference it.Coverity issue: 379202
Fixes ca6eb0f7c836 ("raw/ifpga/base: add PMCI base driver")Signed-off-by Wei Huang <[email protected]>--- drivers/raw/ifpga/base/ifpga_fme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/raw/ifpga/base/ifpga_fme.c +1
-1@@ -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 ;drivers/raw/ifpga/base/ifpga_fme.c +1
-1mgr = 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;
Quoted 3 lines
} else {
--
1.8.3.1