ice: Do not free a preallocated node in ice_sched_add_node()
Subsystems (4)
PATCH 1/1 ice: Do not free a preallocated node in ice_sched_add_node()
ice_devlink_rate_node_new() allocates a scheduler node and stores it in the devlink rate as priv. When the parent is set, ice_devlink_set_parent() passes it to ice_sched_add_node() as prealloc_node. If allocating node->children fails, ice_sched_add_node() frees the node with devm_kfree(), but priv still points to it, and later rate operations (setting tx_max or tx_share, or setting the parent again) use the freed node.
Only free the node when ice_sched_add_node() allocated it.
---
Notes:
Bug was found by kbound, an internal static analysis prototype. The fix was written with the help of Claude Opus 5.5.
Compile-tested only (x86_64 and arm64 allmodconfig, W=1, sparse): I do not have E800 hardware.
drivers/net/ethernet/intel/ice/ice_sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sched.c +2 -1
@@ -210,7 +210,8 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, *node->children, hw->max_children[layer]);if (!node->children) { -devm_kfree (ice_hw_to_dev (hw), node); +if (!prealloc_node) +devm_kfree (ice_hw_to_dev (hw), node);return -ENOMEM ; } }
base-commit: 6055ab4d82e42de89871db03045b568ed706ef50
Signature · 1 line
2.53.0