Merge branch 'net-shaper-follow-ups-to-recent-fixes'

Jakub Kicinski says:

====================
net: shaper: follow ups to recent fixes

As discussed previously on the patch set with real fixes the xa_locking
in shapers is a little confusing, remove it.
Link: https://lore.kernel.org/20260506000628.1501691-2-kuba@kernel.org

The remaining three patches are an attempt to silence AI reviewers,
I believe Sashiko was complaining about these non-issues. Not adding
Reported tags since these are false positives.
====================

Link: https://patch.msgid.link/20260609183224.1108521-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Paolo Abeni 2026-06-11 12:55:25 +02:00
commit 0ce346bf2f

View File

@ -406,7 +406,7 @@ static int net_shaper_pre_insert(struct net_shaper_binding *binding,
prev = xa_store(&hierarchy->shapers, index, cur, GFP_KERNEL);
if (xa_err(prev)) {
NL_SET_ERR_MSG(extack, "Can't insert shaper into device store");
kfree_rcu(cur, rcu);
kfree(cur);
ret = xa_err(prev);
goto free_id;
}
@ -429,7 +429,6 @@ static void net_shaper_commit(struct net_shaper_binding *binding,
int index;
int i;
xa_lock(&hierarchy->shapers);
for (i = 0; i < nr_shapers; ++i) {
index = net_shaper_handle_to_index(&shapers[i].handle);
@ -442,7 +441,6 @@ static void net_shaper_commit(struct net_shaper_binding *binding,
/* ... publish to lockless readers. */
smp_store_release(&cur->valid, true);
}
xa_unlock(&hierarchy->shapers);
}
/* Rollback all the tentative inserts from the hierarchy. */
@ -455,14 +453,12 @@ static void net_shaper_rollback(struct net_shaper_binding *binding)
if (!hierarchy)
return;
xa_lock(&hierarchy->shapers);
xa_for_each(&hierarchy->shapers, index, cur) {
if (cur->valid)
continue;
__xa_erase(&hierarchy->shapers, index);
xa_erase(&hierarchy->shapers, index);
kfree_rcu(cur, rcu);
}
xa_unlock(&hierarchy->shapers);
}
static int net_shaper_parse_handle(const struct nlattr *attr,
@ -1456,6 +1452,8 @@ int net_shaper_nl_cap_get_dumpit(struct sk_buff *skb,
ret = net_shaper_cap_fill_one(skb, binding, scope, flags,
info);
/* cap dumps are tiny, we expect them to fit in a single skb */
WARN_ON_ONCE(ret == -EMSGSIZE);
if (ret)
return ret;
}
@ -1472,12 +1470,14 @@ static void net_shaper_flush(struct net_shaper_binding *binding)
if (!hierarchy)
return;
xa_lock(&hierarchy->shapers);
xa_for_each(&hierarchy->shapers, index, cur) {
__xa_erase(&hierarchy->shapers, index);
xa_erase(&hierarchy->shapers, index);
/* No need to use kfree_rcu(), netdev is already unpublished,
* and synchronize_rcu() has been run as part of
* unregister_netdevice().
*/
kfree(cur);
}
xa_unlock(&hierarchy->shapers);
kfree(hierarchy);
}