* [PATCH iwl-net] ice: Do not free a preallocated node in ice_sched_add_node()
@ 2026-11-19 5:57 Yuqiang Sun
2026-11-26 14:08 ` Simon Horman
2026-11-27 10:04 ` Przemek Kitszel
0 siblings, 2 replies; 3+ messages in thread
From: Yuqiang Sun @ 2026-11-19 5:57 UTC (permalink / raw)
To: anthony.l.nguyen, przemyslaw.kitszel
Cc: m.wilczynski, andrew+netdev, davem, edumazet, kuba, pabeni,
intel-wired-lan, netdev, linux-kernel, stable
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.
Fixes: bdf96d965a20 ("ice: Add an option to pre-allocate memory for ice_sched_node")
Cc: stable@vger.kernel.org
Signed-off-by: Yuqiang Sun <izaiahsun@gmail.com>
---
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(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
index a5c7a4e1ceba..dba6cc912b7b 100644
--- a/drivers/net/ethernet/intel/ice/ice_sched.c
+++ b/drivers/net/ethernet/intel/ice/ice_sched.c
@@ -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
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-net] ice: Do not free a preallocated node in ice_sched_add_node()
2026-11-19 5:57 [PATCH iwl-net] ice: Do not free a preallocated node in ice_sched_add_node() Yuqiang Sun
@ 2026-11-26 14:08 ` Simon Horman
2026-11-27 10:04 ` Przemek Kitszel
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-11-26 14:08 UTC (permalink / raw)
To: Yuqiang Sun
Cc: anthony.l.nguyen, przemyslaw.kitszel, m.wilczynski, andrew+netdev,
davem, edumazet, kuba, pabeni, intel-wired-lan, netdev,
linux-kernel, stable
On Thu, Nov 19, 2026 at 01:57:31PM +0800, Yuqiang Sun wrote:
> 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.
>
> Fixes: bdf96d965a20 ("ice: Add an option to pre-allocate memory for ice_sched_node")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuqiang Sun <izaiahsun@gmail.com>
> ---
>
> 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.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-net] ice: Do not free a preallocated node in ice_sched_add_node()
2026-11-19 5:57 [PATCH iwl-net] ice: Do not free a preallocated node in ice_sched_add_node() Yuqiang Sun
2026-11-26 14:08 ` Simon Horman
@ 2026-11-27 10:04 ` Przemek Kitszel
1 sibling, 0 replies; 3+ messages in thread
From: Przemek Kitszel @ 2026-11-27 10:04 UTC (permalink / raw)
To: Yuqiang Sun, anthony.l.nguyen
Cc: m.wilczynski, andrew+netdev, davem, edumazet, kuba, pabeni,
intel-wired-lan, netdev, linux-kernel
On 11/19/26 6:57 AM, Yuqiang Sun wrote:
> 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.
nit: commit msg is too verbose
>
> Only free the node when ice_sched_add_node() allocated it.
>
> Fixes: bdf96d965a20 ("ice: Add an option to pre-allocate memory for ice_sched_node")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuqiang Sun <izaiahsun@gmail.com>
Thank you for the patch, and props for resolving Michal email to his
current company :)
> ---
>
> 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(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
> index a5c7a4e1ceba..dba6cc912b7b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sched.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sched.c
> @@ -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)
this is correct in machine-code way, and shortest possible C code, but
semantically wrong
the condition should be `if (node != prealloc_node)`
> + devm_kfree(ice_hw_to_dev(hw), node);
> return -ENOMEM;
> }
> }
>
> base-commit: 6055ab4d82e42de89871db03045b568ed706ef50
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-27 10:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 5:57 [PATCH iwl-net] ice: Do not free a preallocated node in ice_sched_add_node() Yuqiang Sun
2026-11-26 14:08 ` Simon Horman
2026-11-27 10:04 ` Przemek Kitszel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox