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 11829A0524; Thu, 6 May 2021 12:07:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2B6C410F7; Thu, 6 May 2021 12:07:15 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 22DDD40040 for ; Thu, 6 May 2021 12:07:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620295634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=12/K0KzcH8AfsjALVfpRzDGw/DCEza8cRD6yXKYT3Zg=; b=Xda/586vQVwi1cwgn9DTtlHKh9iveiAhpFfEnp3W7D3MeIuaigQAX6u+cyJ394h7DoSY0G m9k8+GnvBVTI7+gSZrW64YBHNzRnu5/O20VvoTHwfkGlx8D05mIrwbqV7r492jAJ1J6XLf 4B0Yn6LWNwbgxsweQobp6st/S0ZUnAo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-ssptMroTPTaKC-iN-uLlTw-1; Thu, 06 May 2021 06:07:10 -0400 X-MC-Unique: ssptMroTPTaKC-iN-uLlTw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 751976D246; Thu, 6 May 2021 10:07:09 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4790359460; Thu, 6 May 2021 10:07:06 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Qiming Yang , Qi Zhang , Ferruh Yigit , Wenzhuo Lu Date: Thu, 6 May 2021 12:07:02 +0200 Message-Id: <20210506100702.23778-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH] net/ice/base: fix mem allocations wrapper 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 Sender: "dev" This is reported by our internal covscan: 1. dpdk-20.11/drivers/net/ice/base/ice_switch.c:4214: sign_extension: Suspicious implicit sign extension: "s_rule_size" with type "u16" (16 bits, unsigned) is promoted in "num_unicast * s_rule_size" to type "int" (32 bits, signed), then sign-extended to type "unsigned long" (64 bits, unsigned). If "num_unicast * s_rule_size" is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. # 4212| s_rule_size = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE; # 4213| s_rule = (struct ice_aqc_sw_rules_elem *) # 4214|-> ice_calloc(hw, num_unicast, s_rule_size); # 4215| if (!s_rule) { # 4216| status = ICE_ERR_NO_MEMORY; Even if this condition is not likely to happen, in any case, it is more straightforward to rely on the existing rte_calloc. Fixes: 5f0978e96220 ("net/ice/base: add OS specific implementation") Cc: stable@dpdk.org Signed-off-by: David Marchand --- drivers/net/ice/base/ice_osdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index f4cc762e99..878c5597d4 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -207,7 +207,7 @@ struct ice_virt_mem { } __rte_packed; #define ice_malloc(h, s) rte_zmalloc(NULL, s, 0) -#define ice_calloc(h, c, s) rte_zmalloc(NULL, (c) * (s), 0) +#define ice_calloc(h, c, s) rte_calloc(NULL, c, s, 0) #define ice_free(h, m) rte_free(m) #define ice_memset(a, b, c, d) memset((a), (b), (c)) -- 2.23.0