Skip to content

Commit 82465e0

Browse files
Aleksandr Mishingregkh
authored andcommitted
ice: Adjust over allocation of memory in ice_sched_add_root_node() and ice_sched_add_node()
[ Upstream commit 62fdaf9 ] 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 <[email protected]> Signed-off-by: Aleksandr Mishin <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 21ba713 commit 82465e0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/net/ethernet/intel/ice/ice_sched.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ ice_sched_add_root_node(struct ice_port_info *pi,
2828
if (!root)
2929
return -ENOMEM;
3030

31-
/* coverity[suspicious_sizeof] */
3231
root->children = devm_kcalloc(ice_hw_to_dev(hw), hw->max_children[0],
33-
sizeof(*root), GFP_KERNEL);
32+
sizeof(*root->children), GFP_KERNEL);
3433
if (!root->children) {
3534
devm_kfree(ice_hw_to_dev(hw), root);
3635
return -ENOMEM;
@@ -186,10 +185,9 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,
186185
if (!node)
187186
return -ENOMEM;
188187
if (hw->max_children[layer]) {
189-
/* coverity[suspicious_sizeof] */
190188
node->children = devm_kcalloc(ice_hw_to_dev(hw),
191189
hw->max_children[layer],
192-
sizeof(*node), GFP_KERNEL);
190+
sizeof(*node->children), GFP_KERNEL);
193191
if (!node->children) {
194192
devm_kfree(ice_hw_to_dev(hw), node);
195193
return -ENOMEM;

0 commit comments

Comments
 (0)