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 A108EA0093; Thu, 9 Dec 2021 17:29:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F846410F3; Thu, 9 Dec 2021 17:29:29 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id AEAEF40041; Thu, 9 Dec 2021 17:29:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639067368; x=1670603368; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=sgmBDMEK5q+XWeTXHOq14hUwmgFGG1Qo0IqVU4lPHfc=; b=I5VcM+DvmOLIoAr6O8DyZLP/1zDMlMAFc8Amqo+F5qmWh+VMfkdoQlRD /8L63ztPyfKvONNElrc8LtCmKA9cZzZ8xM++S8wX7zi1psYkXb7TsP9F0 Oc6T31rZ5nlxJqE0VCAsfa0v4UtNyg1+RynjWXs1ojhKgb1O866bV6S/D aMyUvROgqkF3sKVRpGEa+5iTz6tWhfzoBXIRb7ye+Cvx8eLTRX5fwfyAh Zr5npSTkzYIARNKBbH9dhuNGQyn6RCOOZfkvicX25iz68irHfAgH6OZKd tYctMucpsIZYZ8QtHdwRE4YjI69wCSsr/JehaixJNJVMt8ydV0bgfe7uN w==; X-IronPort-AV: E=McAfee;i="6200,9189,10193"; a="238366502" X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="238366502" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 08:28:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="543650521" Received: from silpixa00401215.ir.intel.com ([10.55.128.96]) by orsmga001.jf.intel.com with ESMTP; 09 Dec 2021 08:27:45 -0800 From: Sean Morrissey To: Ori Kam , Xiaoyun Li , Aman Singh Cc: dev@dpdk.org, Sean Morrissey , stable@dpdk.org, wei.zhao1@intel.com Subject: [PATCH v1] app/testpmd: fix dereference before null check Date: Thu, 9 Dec 2021 16:27:27 +0000 Message-Id: <20211209162727.12295-1-sean.morrissey@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Assign 'left' variable only after null check on 'size' as function returns if 'size' is null. Coverity issue: 374381 Fixes: 169a9fed1f4 ("app/testpmd: fix hex string parser support for flow API") Cc: stable@dpdk.org Cc: wei.zhao1@intel.com Signed-off-by: Sean Morrissey --- app/test-pmd/cmdline_flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index bbe3dc0115..5bb7abcced 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7702,7 +7702,6 @@ parse_string(struct context *ctx, const struct token *token, static int parse_hex_string(const char *src, uint8_t *dst, uint32_t *size) { - uint32_t left = *size; const uint8_t *head = dst; /* Check input parameters */ @@ -7712,6 +7711,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size) (*size == 0)) return -1; + uint32_t left = *size; + /* Convert chars to bytes */ while (left) { char tmp[3], *end = tmp; -- 2.25.1