DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andy Pei <andy.pei@intel.com>
To: dev@dpdk.org
Cc: chenbo.xia@intel.com, maxime.coquelin@redhat.com,
	xiao.w.wang@intel.com, rosen.xu@intel.com, qimaix.xiao@intel.com
Subject: [PATCH v2] vdpa/ifc: fix null pointer dereference
Date: Wed, 15 Jun 2022 14:16:56 +0800	[thread overview]
Message-ID: <1655273816-163663-1-git-send-email-andy.pei@intel.com> (raw)

Fix null pointer dereference reported in coverity scan.

Coverity issue: 378882
Fixes: 5d75517beffe ("vdpa/ifc/base: access correct register for blk device")

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/vdpa/ifc/base/ifcvf.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index dd475a7..0a9f71a 100644
--- a/drivers/vdpa/ifc/base/ifcvf.c
+++ b/drivers/vdpa/ifc/base/ifcvf.c
@@ -255,6 +255,10 @@
 	u32 ring_state;
 
 	cfg = hw->common_cfg;
+	if (!cfg) {
+		DEBUGOUT("common_cfg in HW is NULL.\n");
+		return;
+	}
 
 	IFCVF_WRITE_REG16(IFCVF_MSI_NO_VECTOR, &cfg->msix_config);
 	for (i = 0; i < hw->nr_vring; i++) {
@@ -262,6 +266,11 @@
 		IFCVF_WRITE_REG16(0, &cfg->queue_enable);
 		IFCVF_WRITE_REG16(IFCVF_MSI_NO_VECTOR, &cfg->queue_msix_vector);
 
+		if (!hw->lm_cfg) {
+			DEBUGOUT("live migration cfg in HW is NULL.\n");
+			continue;
+		}
+
 		if (hw->device_type == IFCVF_BLK)
 			ring_state = *(u32 *)(hw->lm_cfg +
 					IFCVF_LM_RING_STATE_OFFSET +
-- 
1.8.3.1


             reply	other threads:[~2022-06-15  7:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15  6:16 Andy Pei [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-08  7:34 [PATCH] " Andy Pei
2022-06-15  6:23 ` [PATCH v2] " Andy Pei
2022-06-17 12:40   ` Maxime Coquelin
2022-06-17 14:07   ` Maxime Coquelin
2022-06-18  9:04     ` Pei, Andy

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=1655273816-163663-1-git-send-email-andy.pei@intel.com \
    --to=andy.pei@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=qimaix.xiao@intel.com \
    --cc=rosen.xu@intel.com \
    --cc=xiao.w.wang@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).