diff mbox series

[net-next] mlxsw: core: Fix use-after-free calling devl_unlock() in mlxsw_core_bus_device_unregister()

Message ID 20220721142424.3975704-1-jiri@resnulli.us (mailing list archive)
State Accepted
Commit 1b5995e370e4024e7bb7408247363e8e67f0393d
Delegated to: Netdev Maintainers
Headers show
Series [net-next] mlxsw: core: Fix use-after-free calling devl_unlock() in mlxsw_core_bus_device_unregister() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: jiri@nvidia.com; 1 maintainers not CCed: jiri@nvidia.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Pirko July 21, 2022, 2:24 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

Do devl_unlock() before freeing the devlink in
mlxsw_core_bus_device_unregister() function.

Reported-by: Ido Schimmel <idosch@nvidia.com>
Fixes: 72a4c8c94efa ("mlxsw: convert driver to use unlocked devlink API during init/fini")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ido Schimmel July 21, 2022, 6:01 p.m. UTC | #1
On Thu, Jul 21, 2022 at 04:24:24PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Do devl_unlock() before freeing the devlink in
> mlxsw_core_bus_device_unregister() function.
> 
> Reported-by: Ido Schimmel <idosch@nvidia.com>
> Fixes: 72a4c8c94efa ("mlxsw: convert driver to use unlocked devlink API during init/fini")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>
patchwork-bot+netdevbpf@kernel.org July 22, 2022, 10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 21 Jul 2022 16:24:24 +0200 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Do devl_unlock() before freeing the devlink in
> mlxsw_core_bus_device_unregister() function.
> 
> Reported-by: Ido Schimmel <idosch@nvidia.com>
> Fixes: 72a4c8c94efa ("mlxsw: convert driver to use unlocked devlink API during init/fini")
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net-next] mlxsw: core: Fix use-after-free calling devl_unlock() in mlxsw_core_bus_device_unregister()
    https://git.kernel.org/netdev/net-next/c/1b5995e370e4

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 61eb96b93889..1b61bc8f59a2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -2296,8 +2296,8 @@  void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
 		devl_resources_unregister(devlink);
 	mlxsw_core->bus->fini(mlxsw_core->bus_priv);
 	if (!reload) {
-		devlink_free(devlink);
 		devl_unlock(devlink);
+		devlink_free(devlink);
 	}
 
 	return;
@@ -2305,8 +2305,8 @@  void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
 reload_fail_deinit:
 	mlxsw_core_params_unregister(mlxsw_core);
 	devl_resources_unregister(devlink);
-	devlink_free(devlink);
 	devl_unlock(devlink);
+	devlink_free(devlink);
 }
 EXPORT_SYMBOL(mlxsw_core_bus_device_unregister);