Re: [PATCH net] devlink: fix net namespace reference leak in reload
From: Antoine Tenart
Date: Wed Jul 29 2026 - 06:49:18 EST
On Wed, Jul 29, 2026 at 11:06:00AM +0300, Tariq Toukan wrote:
> From: Or Har-Toov <ohartoov@xxxxxxxxxx>
>
> 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.
>
> Fixes: 2edd92570441 ("devlink: don't allow to change net namespace for FW_ACTIVATE reload action")
> Signed-off-by: Or Har-Toov <ohartoov@xxxxxxxxxx>
> Reviewed-by: Jiri Pirko <jiri@xxxxxxxxxx>
> Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
Reviewed-by: Antoine Tenart <atenart@xxxxxxxxxx>
> ---
> net/devlink/dev.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/devlink/dev.c b/net/devlink/dev.c
> index 57b2b8f03543..fd5633fa88ec 100644
> --- a/net/devlink/dev.c
> +++ b/net/devlink/dev.c
> @@ -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
> --
> 2.44.0
>