devlink rate: Remove unnecessary 'static' from a couple places
authorCosmin Ratiu <cratiu@nvidia.com>
Thu, 18 Sep 2025 10:15:06 +0000 (13:15 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Sep 2025 14:47:18 +0000 (07:47 -0700)
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>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/devlink/rate.c

index 110b3fa8a0b1b1faa9925fb24de5042b30aa46b4..264fb82cba196e9a290d3b9feb4bfd0575cf8da8 100644 (file)
@@ -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);