devlink: fix netns refcount leak in devlink_nl_cmd_reload()
authorEric Dumazet <edumazet@google.com>
Sun, 5 Dec 2021 19:28:22 +0000 (11:28 -0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 7 Dec 2021 00:56:32 +0000 (16:56 -0800)
commit4dbb0dad8e63fcd0b5a117c2861d2abe7ff5f186
tree59be9e2128d788c38e5188e0d9a5a076ed0ed2c0
parentdde91ccfa25fd58f64c397d91b81a4b393100ffa
devlink: fix netns refcount leak in devlink_nl_cmd_reload()

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 <edumazet@google.com>
Cc: Moshe Shemesh <moshe@mellanox.com>
Cc: Jacob Keller <jacob.e.keller@intel.com>
Cc: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20211205192822.1741045-1-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/devlink.c