devlink: fix netns refcount leak in devlink_nl_cmd_reload()
Subsystems (2)
PATCH 1/1 devlink: fix netns refcount leak in devlink_nl_cmd_reload()
From: Eric Dumazet <[email protected]>
While preparing my patch series adding netns refcount tracking, I spotted bugs in devlink_nl_cmd_reload()
Some error paths forgot to release a refcount on a netns.
To fix this, we can reduce the scope of get_net()/put_net() section around the call to devlink_reload().
--- net/core/devlink.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
net/core/devlink.c +8 -8
@@ -4110,14 +4110,6 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)return err; } -if (info->attrs[DEVLINK_ATTR_NETNS_PID ] || - info->attrs[DEVLINK_ATTR_NETNS_FD ] || - info->attrs[DEVLINK_ATTR_NETNS_ID ]) { - dest_net =devlink_netns_get (skb, info); -if (IS_ERR (dest_net)) -return PTR_ERR (dest_net); - } -if (info->attrs[DEVLINK_ATTR_RELOAD_ACTION ]) action =nla_get_u8 (info->attrs[DEVLINK_ATTR_RELOAD_ACTION ]);else
@@ -4160,6 +4152,14 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)return -EINVAL ; } } +if (info->attrs[DEVLINK_ATTR_NETNS_PID ] || + info->attrs[DEVLINK_ATTR_NETNS_FD ] || + info->attrs[DEVLINK_ATTR_NETNS_ID ]) { + dest_net =devlink_netns_get (skb, info); +if (IS_ERR (dest_net)) +return PTR_ERR (dest_net); + } + err =devlink_reload (devlink, dest_net, action, limit, &actions_performed, info->extack);if (dest_net)
Signature · 1 line
2.34.1.400.ga245620fadb-goog
Quoted 17 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
While preparing my patch series adding netns refcount tracking, I spotted bugs in
devlink_nl_cmd_reload()Some error paths forgot to release a refcount on a netns.
To fix this, we can reduce the scope of get_net()/put_net() section around the call to
devlink_reload().Fixes ccdf07219da6 ("devlink: Add reload action option to devlink reload command")Fixes dc64cc7c6310 ("devlink: Add devlink reload limit option")Signed-off-by Eric Dumazet <[email protected]>Cc Moshe Shemesh <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jacob Keller <[email protected]>Cc Jiri Pirko <[email protected]>
Quoted 4 lines
--- net/core/devlink.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Thanks,
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Sun, 5 Dec 2021 11:28:22 -0800 you wrote:
From: Eric Dumazet <[email protected]>
While preparing my patch series adding netns refcount tracking, I spotted bugs in
devlink_nl_cmd_reload()Some error paths forgot to release a refcount on a netns.
[...]
Here is the summary with links:
- [net] devlink: fix netns refcount leak in devlink_nl_cmd_reload()
https://git.kernel.org/netdev/net/c/4dbb0dad8e63
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html