From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 4B10E1B53B; Fri, 5 Apr 2019 16:37:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 07:37:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,313,1549958400"; d="scan'208";a="140280835" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 05 Apr 2019 07:37:24 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Maxime Coquelin , Tiwei Bie , Zhihong Wang Date: Fri, 5 Apr 2019 15:37:06 +0100 Message-Id: <20190405143709.50352-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190405143709.50352-1-bruce.richardson@intel.com> References: <20190405134511.49066-1-bruce.richardson@intel.com> <20190405143709.50352-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter 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: , X-List-Received-Date: Fri, 05 Apr 2019 14:37:27 -0000 Coverity points out that there is a check in the main thread loop for the ctrlr->bdev being NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure. Coverity issue: 158657 Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app") CC: stable@dpdk.org CC: Maxime Coquelin CC: Tiwei Bie CC: Zhihong Wang Signed-off-by: Bruce Richardson --- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/vhost_scsi/vhost_scsi.c b/examples/vhost_scsi/vhost_scsi.c index 2908ff68b..a6465d089 100644 --- a/examples/vhost_scsi/vhost_scsi.c +++ b/examples/vhost_scsi/vhost_scsi.c @@ -285,6 +285,12 @@ ctrlr_worker(void *arg) cpu_set_t cpuset; pthread_t thread; + if (ctrlr == NULL || ctrlr->bdev == NULL) { + fprintf(stdout, "%s: Error, invalid argument passed to worker thread\n", + __func__); + return NULL; + } + thread = pthread_self(); CPU_ZERO(&cpuset); CPU_SET(0, &cpuset); -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 58D1EA0679 for ; Fri, 5 Apr 2019 16:37:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 304ED1B546; Fri, 5 Apr 2019 16:37:29 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 4B10E1B53B; Fri, 5 Apr 2019 16:37:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 07:37:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,313,1549958400"; d="scan'208";a="140280835" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 05 Apr 2019 07:37:24 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Maxime Coquelin , Tiwei Bie , Zhihong Wang Date: Fri, 5 Apr 2019 15:37:06 +0100 Message-Id: <20190405143709.50352-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190405143709.50352-1-bruce.richardson@intel.com> References: <20190405134511.49066-1-bruce.richardson@intel.com> <20190405143709.50352-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190405143706.p6PB4RKx_c9pNjg5Xh0SQ1H6yNiurGtm0KxbxZYHOH8@z> Coverity points out that there is a check in the main thread loop for the ctrlr->bdev being NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure. Coverity issue: 158657 Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app") CC: stable@dpdk.org CC: Maxime Coquelin CC: Tiwei Bie CC: Zhihong Wang Signed-off-by: Bruce Richardson --- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/vhost_scsi/vhost_scsi.c b/examples/vhost_scsi/vhost_scsi.c index 2908ff68b..a6465d089 100644 --- a/examples/vhost_scsi/vhost_scsi.c +++ b/examples/vhost_scsi/vhost_scsi.c @@ -285,6 +285,12 @@ ctrlr_worker(void *arg) cpu_set_t cpuset; pthread_t thread; + if (ctrlr == NULL || ctrlr->bdev == NULL) { + fprintf(stdout, "%s: Error, invalid argument passed to worker thread\n", + __func__); + return NULL; + } + thread = pthread_self(); CPU_ZERO(&cpuset); CPU_SET(0, &cpuset); -- 2.20.1