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 F03D1A0548; Wed, 15 Jun 2022 09:07:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1D1440221; Wed, 15 Jun 2022 09:07:04 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 57B2740220 for ; Wed, 15 Jun 2022 09:07:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655276823; x=1686812823; h=from:to:cc:subject:date:message-id; bh=/h6ByVgkKuzg+JGVfWunhZmZKi6msyhEJavh8K7Bol4=; b=j6GyOnkIFD4xM5MbptsA9N3tKVxz9wmEILkpBIGJ0zrSkEv6JUHTHhgU C6L/LNHydJO/03Be0Fr1sTmggqTyBdYph47xiqrhKJWXlXmkXCGVJ02bB 6txAY4dYCl7MbeYCrKUapQOa5COUcO0a47t2JpgNPzKYnYuxqUk3lO4Fp +7rYJgu11sfEryne4QPTd54Bt2JovqIwHzZr9gp8RyOuDHXb7VcirBxMd nwy7ru5Q5LBC5PK4azuEjBRZZtHAjhzFFIk0zdNCEjb1X3PMuFJ09w2hV dN9g/e4rg9B7kUiNEavoZ+0jjcq1yEC1px9Z1DKNkiqnn/IbJUdcJPPY6 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="365211894" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="365211894" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 00:06:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="830883719" Received: from dpdk-dipei.sh.intel.com ([10.67.110.238]) by fmsmga006.fm.intel.com with ESMTP; 15 Jun 2022 00:06:46 -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:16:56 +0800 Message-Id: <1655273816-163663-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 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 --- 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