From patchwork Fri Apr 5 13:45:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 52343 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E46771B51A; Fri, 5 Apr 2019 15:45:29 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id A469A1B512; Fri, 5 Apr 2019 15:45:27 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 06:45:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,312,1549958400"; d="scan'208";a="140383679" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by fmsmga007.fm.intel.com with ESMTP; 05 Apr 2019 06:45:25 -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 14:45:08 +0100 Message-Id: <20190405134511.49066-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190405134511.49066-1-bruce.richardson@intel.com> References: <20190405134511.49066-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 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" 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);