linux/net/devlink
Cosmin Ratiu ba81a8b80f devlink: Fix parent ref leak on tc-bw failure
When a node is created via rate-new with tc-bw and a parent node,
devlink_nl_rate_set() executes the sequence of ops. It bails out on the
first failure and doesn't rollback anything. For most things that is
fine (setting some numbers), but the parent set can leak if there's
another failure after that.

That is precisely what happens when parent setting isn't the last block
in the function. After the referenced "Fixes" commit, when tc-bw fails
to be set the function bails out after having set the parent and
incremented its refcount.
There are two callers:
- devlink_nl_rate_set_doit() is fine, it just reports the error.
- but devlink_nl_rate_new_doit() frees the newly created node and leaks
  the parent refcnt.

Fix that by reordering the blocks so parent setting is last and adding a
comment explaining this so future modification preserve the ordering
(hopefully).

Fixes: 566e8f108f ("devlink: Extend devlink rate API with traffic classes bandwidth management")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260616110633.1449432-3-cratiu@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-18 18:02:29 -07:00
..
core.c devlink: Release nested relation on devlink free 2026-06-01 19:54:52 -07:00
dev.c devlink: allow devlink instance allocation without a backing device 2026-03-14 13:08:49 -07:00
devl_internal.h devlink: Include port resources in resource dump dumpit 2026-04-08 19:55:38 -07:00
dpipe.c
health.c devlink: Fix incorrect skb socket family dumping 2026-04-08 19:34:38 -07:00
linecard.c
Makefile devlink: introduce shared devlink instance for PFs on same chip 2026-03-14 13:08:50 -07:00
netlink_gen.c devlink: Implement devlink param multi attribute nested data values 2026-06-13 16:16:58 -07:00
netlink_gen.h devlink: Add port-specific option to resource dump doit 2026-04-08 19:55:39 -07:00
netlink.c devlink: Include port resources in resource dump dumpit 2026-04-08 19:55:38 -07:00
param.c devlink: Implement devlink param multi attribute nested data values 2026-06-13 16:16:58 -07:00
port.c devlink: Add port-level resource registration infrastructure 2026-04-08 19:55:38 -07:00
rate.c devlink: Fix parent ref leak on tc-bw failure 2026-06-18 18:02:29 -07:00
region.c
resource.c devlink: Warn on resource ID collision with PARENT_TOP 2026-06-15 12:41:41 -07:00
sb.c
sh_dev.c devlink: introduce shared devlink instance for PFs on same chip 2026-03-14 13:08:50 -07:00
trap.c