[PATCH net 2/2] rtnetlink: Release nets when leaving rtnl_setlink()
From: Bastien Curutchet (eBPF Foundation)
Date: Wed Feb 12 2025 - 03:25:29 EST
rtnl_setlink() uses the rtnl_nets_* helpers but never calls the
rtnl_nets_destroy(). It leads to small memory leaks.
Call rtnl_nets_destroy() before exiting to properly decrement the nets'
reference counters.
Fixes: 636af13f213b ("rtnetlink: Register rtnl_dellink() and rtnl_setlink() with RTNL_FLAG_DOIT_PERNET_WIP.")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@xxxxxxxxxxx>
---
net/core/rtnetlink.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 94111d3383788566f2296039e68549e2b40d5a4a..e4ac14c081a48e36f5381e025a3991c90827c2bf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3441,6 +3441,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
rtnl_nets_unlock(&rtnl_nets);
errout:
+ rtnl_nets_destroy(&rtnl_nets);
return err;
}
--
2.48.1