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 86FDF454EF; Tue, 25 Jun 2024 13:20:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55ACC42EFF; Tue, 25 Jun 2024 13:16:44 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 3EA1D427A0 for ; Tue, 25 Jun 2024 13:16:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314165; x=1750850165; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PmoQQYJYtL1XG6LqyWFBOvcUA+II2N+4XtEGMb7EvZc=; b=BRqhk1Kz2B500pVl7hELmQalvkn9DSF2g1UQsAKpd1TNIx8HDxLrHZIq mLgctElQyuOkvySRMY5RfW78Or+fA/IbR9UGoRuxWIsR0hEDxeI+nBNKB 0Lcqs7Ixc0fhSu+4VImX+eRmnCqSH/huYfoWWye0cCz4BW/8V+E9ryYDE +9HlMpCAs/M6FThmPPqwvm5wcql5OCJIUCr6wWemdl4LJw1T7srU7rqy4 sPfP0R89Fr6TbvnHWcDbctNClrfF3BG9oaDVoXVAFS5jo5O4XeADUvjV+ YUb845lAyoip0V6I0hEm147RycQ0uT27Bt4nujWdOsn8izoDpcBowpN5z Q==; X-CSE-ConnectionGUID: vt38I2LTTiGuvQzIVHPdNQ== X-CSE-MsgGUID: 4HW2lVseRvaKy5yuvDuVsA== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080180" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080180" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 04:16:04 -0700 X-CSE-ConnectionGUID: 5VGHMh6wRJm9CNwoutGsMA== X-CSE-MsgGUID: bbGRV50MSuSOxepNqyr+DQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719156" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:16:04 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Jacob Keller , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 040/129] net/ice/base: fix incorrect size when allocating children arrays Date: Tue, 25 Jun 2024 12:12:45 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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 From: Jacob Keller The ice_sched_add_root_node() and ice_sched_add_node() functions have comments to suppress Coverity warnings about a suspicious sizeof used when allocating the children array of an struct ice_sched_node. The size is calculated using the size of the scheduler node, which overallocates the array by a significant amount. Fix the code to correctly calculate the size by using *root->children and *node->children respectively. This saves some memory and allows us to drop the Coverity suppression comments. Signed-off-by: Jacob Keller Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_sched.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c index c9d70fb043..74d57329da 100644 --- a/drivers/net/ice/base/ice_sched.c +++ b/drivers/net/ice/base/ice_sched.c @@ -28,9 +28,8 @@ ice_sched_add_root_node(struct ice_port_info *pi, if (!root) return ICE_ERR_NO_MEMORY; - /* coverity[suspicious_sizeof] */ root->children = (struct ice_sched_node **) - ice_calloc(hw, hw->max_children[0], sizeof(*root)); + ice_calloc(hw, hw->max_children[0], sizeof(*root->children)); if (!root->children) { ice_free(hw, root); return ICE_ERR_NO_MEMORY; @@ -186,9 +185,9 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, if (!node) return ICE_ERR_NO_MEMORY; if (hw->max_children[layer]) { - /* coverity[suspicious_sizeof] */ node->children = (struct ice_sched_node **) - ice_calloc(hw, hw->max_children[layer], sizeof(*node)); + ice_calloc(hw, hw->max_children[layer], + sizeof(*node->children)); if (!node->children) { ice_free(hw, node); return ICE_ERR_NO_MEMORY; -- 2.43.0