devlink: fix net namespace reference leak in reload
Subsystems (3)
PATCH 1/1 devlink: fix net namespace reference leak in reload
From: Or Har-Toov <[email protected]>
devlink_nl_reload_doit() calls devlink_netns_get(), which returns a net with a held reference. When the requested namespace differs from the current one and the reload action is not DRIVER_REINIT, the function returns -EOPNOTSUPP without releasing the reference. Add the missing put_net() on this error path.
--- net/devlink/dev.c | 1 + 1 file changed, 1 insertion(+)
net/devlink/dev.c +1 -0
@@ -578,6 +578,7 @@ int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info) action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT) {NL_SET_ERR_MSG_MOD (info->extack,"Changing namespace is only supported for reinit action" ); +put_net (dest_net);return -EOPNOTSUPP ; } }
base-commit: 3bd438a58e910db5dc369aa25dfed1fc95f1b596
Signature · 1 line
2.44.0
Quoted 8 lines · Tariq Toukan
From: Or Har-Toov <[email protected]>
devlink_nl_reload_doit()callsdevlink_netns_get(), which returns a net with a held reference. When the requested namespace differs from the current one and the reload action is notDRIVER_REINIT, the function returns-EOPNOTSUPPwithout releasing the reference. Add the missingput_net()on this error path.
Quoted 4 lines
Fixes 2edd92570441 ("devlink: don't allow to change net namespace for FW_ACTIVATE reload action")Signed-off-by Or Har-Toov <[email protected]>Reviewed-by Jiri Pirko <[email protected]>Signed-off-by Tariq Toukan <[email protected]>
Quoted 21 lines
--- net/devlink/dev.c | 1 + 1 file changed, 1 insertion(+)net/devlink/dev.c +1
-0@@ -578,6 +578,7 @@ int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info) action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT) {NL_SET_ERR_MSG_MOD (info->extack,"Changing namespace is only supported for reinit action" ); +put_net (dest_net);return -EOPNOTSUPP ; } }base-commit:
3bd438a58e910db5dc369aa25dfed1fc95f1b596Signature · 1 line
2.44.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 29 Jul 2026 11:06:00 +0300 you wrote:
From: Or Har-Toov <[email protected]>
devlink_nl_reload_doit()callsdevlink_netns_get(), which returns a net with a held reference. When the requested namespace differs from the current one and the reload action is notDRIVER_REINIT, the function returns-EOPNOTSUPPwithout releasing the reference. Add the missingput_net()on this error path.[...]
Here is the summary with links:
- [net] devlink: fix net namespace reference leak in reload
https://git.kernel.org/netdev/net/c/1c4dac9bf1d2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html