All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] devlink rate: Remove unnecessary 'static' from a couple places
@ 2025-09-18 10:15 Cosmin Ratiu
  2025-09-18 15:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Cosmin Ratiu @ 2025-09-18 10:15 UTC (permalink / raw)
  To: netdev, cratiu
  Cc: Jiri Pirko, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Vlad Buslov, Dmytro Linkin

devlink_rate_node_get_by_name() and devlink_rate_nodes_destroy() have a
couple of unnecessary static variables for iterating over devlink rates.

This could lead to races/corruption/unhappiness if two concurrent
operations execute the same function.

Remove 'static' from both. It's amazing this was missed for 4+ years.
While at it, I confirmed there are no more examples of this mistake in
net/ with 1, 2 or 3 levels of indentation.

Fixes: a8ecb93ef03d ("devlink: Introduce rate nodes")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
---
 net/devlink/rate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/devlink/rate.c b/net/devlink/rate.c
index 110b3fa8a0b1..264fb82cba19 100644
--- a/net/devlink/rate.c
+++ b/net/devlink/rate.c
@@ -34,7 +34,7 @@ devlink_rate_leaf_get_from_info(struct devlink *devlink, struct genl_info *info)
 static struct devlink_rate *
 devlink_rate_node_get_by_name(struct devlink *devlink, const char *node_name)
 {
-	static struct devlink_rate *devlink_rate;
+	struct devlink_rate *devlink_rate;
 
 	list_for_each_entry(devlink_rate, &devlink->rate_list, list) {
 		if (devlink_rate_is_node(devlink_rate) &&
@@ -819,8 +819,8 @@ EXPORT_SYMBOL_GPL(devl_rate_leaf_destroy);
  */
 void devl_rate_nodes_destroy(struct devlink *devlink)
 {
-	static struct devlink_rate *devlink_rate, *tmp;
 	const struct devlink_ops *ops = devlink->ops;
+	struct devlink_rate *devlink_rate, *tmp;
 
 	devl_assert_locked(devlink);
 
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] devlink rate: Remove unnecessary 'static' from a couple places
  2025-09-18 10:15 [PATCH net] devlink rate: Remove unnecessary 'static' from a couple places Cosmin Ratiu
@ 2025-09-18 15:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-18 15:00 UTC (permalink / raw)
  To: Cosmin Ratiu
  Cc: netdev, jiri, davem, edumazet, kuba, pabeni, horms, vladbu,
	dlinkin

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 18 Sep 2025 13:15:06 +0300 you wrote:
> devlink_rate_node_get_by_name() and devlink_rate_nodes_destroy() have a
> couple of unnecessary static variables for iterating over devlink rates.
> 
> This could lead to races/corruption/unhappiness if two concurrent
> operations execute the same function.
> 
> Remove 'static' from both. It's amazing this was missed for 4+ years.
> While at it, I confirmed there are no more examples of this mistake in
> net/ with 1, 2 or 3 levels of indentation.
> 
> [...]

Here is the summary with links:
  - [net] devlink rate: Remove unnecessary 'static' from a couple places
    https://git.kernel.org/netdev/net/c/3191df0a4882

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-18 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 10:15 [PATCH net] devlink rate: Remove unnecessary 'static' from a couple places Cosmin Ratiu
2025-09-18 15:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.