DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wei Huang <wei.huang@intel.com>
To: dev@dpdk.org, thomas@monjalon.net, nipun.gupta@nxp.com,
	hemant.agrawal@nxp.com
Cc: stable@dpdk.org, rosen.xu@intel.com, tianfei.zhang@intel.com,
	qi.z.zhang@intel.com, Wei Huang <wei.huang@intel.com>
Subject: [PATCH] raw/ifpga/base: check pointer before dereference
Date: Wed, 22 Jun 2022 23:11:30 -0400	[thread overview]
Message-ID: <1655953890-26163-1-git-send-email-wei.huang@intel.com> (raw)

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>
---
 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	other threads:[~2022-06-23  3:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  3:11 Wei Huang [this message]
2022-06-23  5:51 ` Zhang, Tianfei
2022-06-26 10:21   ` Thomas Monjalon
2022-06-23  6:25 ` Xu, Rosen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1655953890-26163-1-git-send-email-wei.huang@intel.com \
    --to=wei.huang@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=nipun.gupta@nxp.com \
    --cc=qi.z.zhang@intel.com \
    --cc=rosen.xu@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=tianfei.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).