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 6D2D74404F; Wed, 12 Jun 2024 17:12:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71F1442DE4; Wed, 12 Jun 2024 17:04:49 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id B71D640E48 for ; Wed, 12 Jun 2024 17:04:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204680; x=1749740680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KoZLVvujU7aXPciHYp1L1/1okhgxWZ5NiK3irYeIMdg=; b=Cs+f+Lwr5CiqXaPgkmzMTQFLaHjXpHtLUuZtV50/GRBY0qq4nl0b2MHK 0FG2unIqYti1g3YjGZOzl+neyGW1a9gpDIkbjkjHga+sOqQEzQnkEQcE6 F90n+mGW9oXrJhtVcqZF4hr9bT8khCv6JQDToXL+6oZsO3jfQu/iYCrAC jRY/YezGtEgp4mJWOepunXSKFJcL7nC19kR1aDjT5jLDg5NWIUVp1JuWP UyTBHeEEHUgdkVpDFU4gua/M+1mSojQmleM4VyMaTlvv+37Q26NuuAhDv ZhNAxvW3fSCXPLYrQxttW4EkJLq+VBY8DIcQqD2vSjwWowExnG6SmNHnD g==; X-CSE-ConnectionGUID: GacoGAM1Sx2rCVdOwtwrpA== X-CSE-MsgGUID: arBx8uyaRiCk67iAj0cpUw== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32459519" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32459519" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 08:04:39 -0700 X-CSE-ConnectionGUID: nAqXEhXgStmgZ1Oieqd4ag== X-CSE-MsgGUID: ft2X1Kx1QJGvOqWJxYVxOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39925299" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:04:38 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Ian Stokes , bruce.richardson@intel.com, Jacob Keller Subject: [PATCH v2 051/148] net/ice/base: fix incorrect size when allocating children arrays Date: Wed, 12 Jun 2024 16:00:45 +0100 Message-ID: <6422b94313e69d37e665d938d87ce895e6862747.1718204528.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20240430154014.1026-1-ian.stokes@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 From: Ian Stokes 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