From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 306D1A0548; Wed, 15 Jun 2022 09:13:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 214D0415D7; Wed, 15 Jun 2022 09:13:30 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 1763F40220 for ; Wed, 15 Jun 2022 09:13:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655277208; x=1686813208; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=rwDhHoh8ORA/6T7/xhrUzv1n3d9fXResONfBLxFNXdc=; b=NWfGLYzv5s+uUHoLeSXz0E2e6lwpwpSmO/x3Hs+2/IJYb0wzHfYUqSOh oyZ1L551N0bdgsQ2w/MqYlPbWAQLhiGi2ezG7zAy0a+70Nr9iBCeHzSQy 0/LlK0AmOmqoWAEIsQxIjmAsyZgmFDUC0vwvu7fsaoPFp3K4wLdcV6J2p fARhUcB9jRWbDezdLa+1Lu/0JewVqzcSZ8zLRPaC7oo63v/b9OlKh3xxX 1a8Grxeo0yIx1gnizvS9Yw7LzmsOj1OhUBTS9Md+7nKw/KUugk3YWMOPb aRs0ht0jsAFHGZkapvo9N6pt4KiG+mETUtBBVIqmlzYJ/NFOpVcxEQNfo w==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="279580909" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="279580909" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 00:13:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="640838772" Received: from dpdk-dipei.sh.intel.com ([10.67.110.238]) by fmsmga008.fm.intel.com with ESMTP; 15 Jun 2022 00:13:24 -0700 From: Andy Pei 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:23:34 +0800 Message-Id: <1655274214-164117-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1654673642-151882-1-git-send-email-andy.pei@intel.com> References: <1654673642-151882-1-git-send-email-andy.pei@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Xiao Wang --- 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