Skip to content

Commit 7ec4cd3

Browse files
vadimp-nvidiaij-intel
authored andcommitted
platform: mellanox: Fix a resource leak in an error handling path in probing flow
Fix missed resource deallocation in rollback flows. Currently if an error occurs after a successful mlxplat_i2c_main_init(), mlxplat_i2c_main_exit() call is missed in rollback flow. Thus, some resources are not de-allocated. Move mlxplat_pre_exit() call from mlxplat_remove() into mlxplat_i2c_main_exit(). Call mlxplat_i2c_main_exit() instead of calling mlxplat_pre_exit() in mlxplat_probe() error handling flow. Unregister 'priv->pdev_i2c' device in mlxplat_i2c_main_init() cleanup flow if this device was successfully registered. Fixes: 158cd83 ("platform: mellanox: Split logic in init and exit flow") Reported-by: Christophe JAILLET <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/T/ Signed-off-by: Vadim Pasternak <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 0bb80ec commit 7ec4cd3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/platform/x86/mlx-platform.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6514,13 +6514,15 @@ static int mlxplat_i2c_main_init(struct mlxplat_priv *priv)
65146514
return 0;
65156515

65166516
fail_mlxplat_i2c_mux_topology_init:
6517+
platform_device_unregister(priv->pdev_i2c);
65176518
fail_platform_i2c_register:
65186519
fail_mlxplat_mlxcpld_verify_bus_topology:
65196520
return err;
65206521
}
65216522

65226523
static void mlxplat_i2c_main_exit(struct mlxplat_priv *priv)
65236524
{
6525+
mlxplat_pre_exit(priv);
65246526
mlxplat_i2c_mux_topology_exit(priv);
65256527
if (priv->pdev_i2c)
65266528
platform_device_unregister(priv->pdev_i2c);
@@ -6597,7 +6599,7 @@ static int mlxplat_probe(struct platform_device *pdev)
65976599

65986600
fail_register_reboot_notifier:
65996601
fail_regcache_sync:
6600-
mlxplat_pre_exit(priv);
6602+
mlxplat_i2c_main_exit(priv);
66016603
fail_mlxplat_i2c_main_init:
66026604
fail_regmap_write:
66036605
fail_alloc:
@@ -6614,7 +6616,6 @@ static int mlxplat_remove(struct platform_device *pdev)
66146616
pm_power_off = NULL;
66156617
if (mlxplat_reboot_nb)
66166618
unregister_reboot_notifier(mlxplat_reboot_nb);
6617-
mlxplat_pre_exit(priv);
66186619
mlxplat_i2c_main_exit(priv);
66196620
mlxplat_post_exit();
66206621
return 0;

0 commit comments

Comments
 (0)