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 35D1EA00C3; Tue, 18 Jan 2022 11:53:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 250B142705; Tue, 18 Jan 2022 11:53:20 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id DCBB24068E; Tue, 18 Jan 2022 11:53:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642503199; x=1674039199; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lmXDUVyke4N7DgsrkjhFNr6hg6XNQ2uv2JDNKToX1oo=; b=T/pTX0YDSkzYLMOYLZM3+gu6DV0MXjgrW9+oe8QChu0aZM8iXPocE7O/ QlVQv6D7wyZeaQWU927mASk0sAJxDAvQnUozTJ5BNfulmvAx6FC4MTmXP kMiKs8/l3hMAzNGeML3rZfJxzd70mmgo91hIR7UItyEKdgAM/AC8/PNke 9KeFywK1tfPrNxhqMIbo+Mx8Tz3GpgCPkUku9LDSGbxaTfAh0hVWLSKGi IhHlo29LplhAWcwqNap5gvU6ghQNUStVbZ6Fvdj8IDJ2FYLd2T5UvQAE7 aA1NH3QxWM/uTzGoXH/rsB90rDUdeoIf22TruGaSADqLy1r9noEHBHyzS Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="244983122" X-IronPort-AV: E=Sophos;i="5.88,297,1635231600"; d="scan'208";a="244983122" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 02:53:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,297,1635231600"; d="scan'208";a="517719461" Received: from silpixa00401215.ir.intel.com ([10.55.128.96]) by orsmga007.jf.intel.com with ESMTP; 18 Jan 2022 02:53:15 -0800 From: Sean Morrissey To: Ori Kam , Xiaoyun Li , Aman Singh , Yuying Zhang Cc: dev@dpdk.org, Sean Morrissey , stable@dpdk.org, wei.zhao1@intel.com, Ferruh Yigit Subject: [PATCH v2] app/testpmd: fix dereference before null check Date: Tue, 18 Jan 2022 10:53:09 +0000 Message-Id: <20220118105309.1362804-1-sean.morrissey@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209162727.12295-1-sean.morrissey@intel.com> References: <20211209162727.12295-1-sean.morrissey@intel.com> 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 Reviewed-by: Ferruh Yigit --- app/test-pmd/cmdline_flow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 5c2bba48ad..bbaf18d76e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7702,8 +7702,8 @@ 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; + uint32_t left; /* Check input parameters */ if ((src == NULL) || @@ -7712,6 +7712,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size) (*size == 0)) return -1; + left = *size; + /* Convert chars to bytes */ while (left) { char tmp[3], *end = tmp; -- 2.25.1