[PATCH] raw/ifpga/base: check pointer before dereference

Zhang, Tianfei tianfei.zhang at intel.com
Thu Jun 23 07:51:52 CEST 2022



> -----Original Message-----
> From: Huang, Wei <wei.huang at intel.com>
> Sent: Thursday, June 23, 2022 11:12 AM
> To: dev at dpdk.org; thomas at monjalon.net; nipun.gupta at nxp.com;
> hemant.agrawal at nxp.com
> Cc: stable at dpdk.org; Xu, Rosen <rosen.xu at intel.com>; Zhang, Tianfei
> <tianfei.zhang at intel.com>; Zhang, Qi Z <qi.z.zhang at intel.com>; Huang, Wei
> <wei.huang at 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 at 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 at intel.com>



More information about the stable mailing list