From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 147BFA00E6 for ; Mon, 5 Aug 2019 07:51:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E125A1BE47; Mon, 5 Aug 2019 07:51:34 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 66AC11BE3B; Mon, 5 Aug 2019 07:51:33 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Aug 2019 22:51:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,348,1559545200"; d="scan'208";a="176212824" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.5]) by orsmga003.jf.intel.com with ESMTP; 04 Aug 2019 22:51:06 -0700 Date: Mon, 5 Aug 2019 13:50:41 +0800 From: Ye Xiaolong To: Xiaoyun Li Cc: jingjing.wu@intel.com, dev@dpdk.org, stable@dpdk.org Message-ID: <20190805055041.GF51603@intel.com> References: <20190805050247.28624-1-xiaoyun.li@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190805050247.28624-1-xiaoyun.li@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH] raw/ntb: fix null pointer dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 08/05, Xiaoyun Li wrote: >This patch fixes null pointer dereference issues found by coverity scan. > >Coverity issue: 344981, 344991, 345000, 345002, 345006, 345024 >Fixes: 277310027965 ("raw/ntb: introduce NTB raw device driver") >Cc: stable@dpdk.org > >Signed-off-by: Xiaoyun Li >--- > drivers/raw/ntb/ntb.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > >diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c >index 4ba2f3a38..bfecce1e4 100644 >--- a/drivers/raw/ntb/ntb.c >+++ b/drivers/raw/ntb/ntb.c >@@ -447,14 +447,16 @@ static int > ntb_attr_set(struct rte_rawdev *dev, const char *attr_name, > uint64_t attr_value) > { >- struct ntb_hw *hw = dev->dev_private; >- int index = 0; >+ struct ntb_hw *hw; >+ int index; > > if (dev == NULL || attr_name == NULL) { > NTB_LOG(ERR, "Invalid arguments for setting attributes"); > return -EINVAL; > } > >+ hw = dev->dev_private; >+ > if (!strncmp(attr_name, NTB_SPAD_USER, NTB_SPAD_USER_LEN)) { > if (hw->ntb_ops->spad_write == NULL) > return -ENOTSUP; >@@ -475,14 +477,16 @@ static int > ntb_attr_get(struct rte_rawdev *dev, const char *attr_name, > uint64_t *attr_value) > { >- struct ntb_hw *hw = dev->dev_private; >- int index = 0; >+ struct ntb_hw *hw; >+ int index; > > if (dev == NULL || attr_name == NULL || attr_value == NULL) { > NTB_LOG(ERR, "Invalid arguments for getting attributes"); > return -EINVAL; > } > >+ hw = dev->dev_private; >+ > if (!strncmp(attr_name, NTB_TOPO_NAME, NTB_ATTR_NAME_LEN)) { > *attr_value = hw->topo; > NTB_LOG(INFO, "Attribute (%s) Value (%" PRIu64 ")", >@@ -735,7 +739,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id) > > if (pci_dev == NULL) { > NTB_LOG(ERR, "Invalid pci_dev."); >- ret = -EINVAL; >+ return -EINVAL; > } > > memset(name, 0, sizeof(name)); >@@ -750,7 +754,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id) > socket_id); > if (rawdev == NULL) { > NTB_LOG(ERR, "Unable to allocate rawdev."); >- ret = -EINVAL; >+ return -EINVAL; > } > > rawdev->dev_ops = &ntb_ops; >@@ -766,7 +770,7 @@ ntb_create(struct rte_pci_device *pci_dev, int socket_id) > return ret; > > fail: >- if (rawdev) >+ if (rawdev != NULL) > rte_rawdev_pmd_release(rawdev); > > return ret; >-- >2.17.1 > Reviewed-by: Xiaolong Ye