From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF0E81DEFE3; Tue, 8 Oct 2024 13:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728393238; cv=none; b=rSP8nsXcYS07NZvfnVNYKiF4pX1fn2w04MwuosRnbn5cjeqVgATrDWb4FnfS+tITjOl339XSjz370v65stNXS3s0+ut88mWFwLayqTiwufN9lLzY1izw1E9MsHKvkZez5SgvN6HDMwpEcT7B6ZewxqIBS2O/SJ7Vq/9mxVsOElk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728393238; c=relaxed/simple; bh=8GlkaPJe9jAJZrvBfCIcsDd14CG0w1KUsQbPP1bmeEs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A65IHgbWNga5G0RTu6g5njmR8yaX++mkQ7Li6qBdUXZG+me9RHVM+polajUg3oEhgBtZBGxnoohnUhA5/aItHG8h+CHJSu2FD84DRWosHWSp2GE5py1lwQyi8LMEb65+TKuSHX5VkcVC7SsZZyECM5/CD7Y3GNqC4M00xQdtZ3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ff7vUF0H; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ff7vUF0H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0D5AC4CECD; Tue, 8 Oct 2024 13:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728393238; bh=8GlkaPJe9jAJZrvBfCIcsDd14CG0w1KUsQbPP1bmeEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ff7vUF0HBS/bu2UFSabOiL/C+mSnebWUL3fWtFly2+knsyO9bGq9koaaGR3BW6POc S2pzOOZPU9pvVAcLkXlvEOfooZTrzlZ9EfU46vn0xylnbdwAHkcZWZHT/Q4thNBzqB kAD9vWtqUGqSMPe0X0bpoTCPhKrYuASMky7oE9JU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Przemek Kitszel , Aleksandr Mishin , Simon Horman , Tony Nguyen , Sasha Levin , Pucha Himasekhar Reddy Subject: [PATCH 6.6 062/386] ice: Adjust over allocation of memory in ice_sched_add_root_node() and ice_sched_add_node() Date: Tue, 8 Oct 2024 14:05:07 +0200 Message-ID: <20241008115631.908263839@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115629.309157387@linuxfoundation.org> References: <20241008115629.309157387@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aleksandr Mishin [ Upstream commit 62fdaf9e8056e9a9e6fe63aa9c816ec2122d60c6 ] In ice_sched_add_root_node() and ice_sched_add_node() there are calls to devm_kcalloc() in order to allocate memory for array of pointers to 'ice_sched_node' structure. But incorrect types are used as sizeof() arguments in these calls (structures instead of pointers) which leads to over allocation of memory. Adjust over allocation of memory by correcting types in devm_kcalloc() sizeof() arguments. Found by Linux Verification Center (linuxtesting.org) with SVACE. Reviewed-by: Przemek Kitszel Signed-off-by: Aleksandr Mishin Reviewed-by: Simon Horman Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_sched.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c index c0533d7b66b99..908bcd0738033 100644 --- a/drivers/net/ethernet/intel/ice/ice_sched.c +++ b/drivers/net/ethernet/intel/ice/ice_sched.c @@ -28,9 +28,8 @@ ice_sched_add_root_node(struct ice_port_info *pi, if (!root) return -ENOMEM; - /* coverity[suspicious_sizeof] */ root->children = devm_kcalloc(ice_hw_to_dev(hw), hw->max_children[0], - sizeof(*root), GFP_KERNEL); + sizeof(*root->children), GFP_KERNEL); if (!root->children) { devm_kfree(ice_hw_to_dev(hw), root); return -ENOMEM; @@ -186,10 +185,9 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, if (!node) return -ENOMEM; if (hw->max_children[layer]) { - /* coverity[suspicious_sizeof] */ node->children = devm_kcalloc(ice_hw_to_dev(hw), hw->max_children[layer], - sizeof(*node), GFP_KERNEL); + sizeof(*node->children), GFP_KERNEL); if (!node->children) { devm_kfree(ice_hw_to_dev(hw), node); return -ENOMEM; -- 2.43.0