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 C60A3A0524; Fri, 6 Nov 2020 04:31:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6B159126B; Fri, 6 Nov 2020 04:31:57 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id D8897100C for ; Fri, 6 Nov 2020 04:31:54 +0100 (CET) IronPort-SDR: wa9nyPw9X0BGV4Ok7RkmsNGg+ufOvNHd9Yr7hSnbf9YyuPtGoVwOXoI7wFX1FsmfUQ3Wkgs6Ft 1pcu6aVEQKOA== X-IronPort-AV: E=McAfee;i="6000,8403,9796"; a="157276069" X-IronPort-AV: E=Sophos;i="5.77,454,1596524400"; d="scan'208";a="157276069" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 19:31:52 -0800 IronPort-SDR: Upjw/wEVvd0doXgeqp5kgsQYMhhq9pmO4zRyRRfBQzDiT48oAPru7Rpn6yW3jcAaj9ZsDp/ocB TcId6CVLqdnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,454,1596524400"; d="scan'208";a="528197914" Received: from dpdk_jiangcheng.sh.intel.com ([10.67.119.112]) by fmsmga006.fm.intel.com with ESMTP; 05 Nov 2020 19:31:51 -0800 From: Cheng Jiang To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, patrick.fu@intel.com, YvonneX.Yang@intel.com, Cheng Jiang Date: Fri, 6 Nov 2020 03:23:43 +0000 Message-Id: <20201106032343.9099-1-Cheng1.jiang@intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue 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" Add checking return value of string split function to fix the coverity issue. Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing") Coverity issue: 363739 Signed-off-by: Cheng Jiang --- examples/vhost/ioat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c index b2c74f6537..04806c02d7 100644 --- a/examples/vhost/ioat.c +++ b/examples/vhost/ioat.c @@ -54,9 +54,14 @@ open_ioat(const char *value) } args_nr = rte_strsplit(substr, strlen(substr), dma_arg, MAX_VHOST_DEVICE, ','); - do { + while (i < args_nr) { char *arg_temp = dma_arg[i]; - rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@'); + uint8_t sub_nr; + sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@'); + if (sub_nr != 2) { + ret = -1; + goto out; + } start = strstr(ptrs[0], "txd"); if (start == NULL) { @@ -105,7 +110,7 @@ open_ioat(const char *value) dma_info->nr++; i++; - } while (i < args_nr); + } out: free(input); return ret; -- 2.29.2