platform/x86: Add fixes and amendments for init()/exit() flows
cover platform/x86: Add fixes and amendments for init()/exit() flows
The patchset:
- Fixes memory leak in error handling flow.
- Add cosmetic changes - misspelling fix, better naming/
Patches #1: Fixes memory leak issue.
Patch #2: Fix misspelling.
Patches #3: Renames few routines for better naming convention.
Vadim Pasternak (3):
platform: mellanox: Fix a resource leak in an error handling path in
probing flow
platform: mellanox: Fix misspelling error in routine name
platform: mellanox: Rename some init()/exit() functions for consistent
naming
drivers/platform/x86/mlx-platform.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 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.
--- drivers/platform/x86/mlx-platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/mlx-platform.c +3 -2
@@ -6514,6 +6514,7 @@ static int mlxplat_i2c_main_init(struct mlxplat_priv *priv)return 0 ; fail_mlxplat_i2c_mux_topology_init: +platform_device_unregister (priv->pdev_i2c); fail_platform_i2c_register: fail_mlxplat_mlxcpld_verify_bus_topology:return err;
@@ -6521,6 +6522,7 @@ static int mlxplat_i2c_main_init(struct mlxplat_priv *priv)static void mlxplat_i2c_main_exit (struct mlxplat_priv *priv) { +mlxplat_pre_exit (priv);mlxplat_i2c_mux_topology_exit (priv);if (priv->pdev_i2c)platform_device_unregister (priv->pdev_i2c);
@@ -6597,7 +6599,7 @@ static int mlxplat_probe(struct platform_device *pdev) fail_register_reboot_notifier: fail_regcache_sync: -mlxplat_pre_exit (priv); +mlxplat_i2c_main_exit (priv); fail_mlxplat_i2c_main_init: fail_regmap_write: fail_alloc:
@@ -6614,7 +6616,6 @@ static int mlxplat_remove(struct platform_device *pdev) pm_power_off =NULL ;if (mlxplat_reboot_nb)unregister_reboot_notifier (mlxplat_reboot_nb); -mlxplat_pre_exit (priv);mlxplat_i2c_main_exit (priv);mlxplat_post_exit ();return 0 ;
Signature · 1 line
2.20.1
Re: [PATCH platform 1/3] platform: mellanox: Fix a resource leak in an error handling path in probing flow
Quoted 55 lines · Vadim Pasternak
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 frommlxplat_remove()intomlxplat_i2c_main_exit().Call
mlxplat_i2c_main_exit()instead of callingmlxplat_pre_exit()inmlxplat_probe()error handling flow.Unregister '
priv->pdev_i2c' device inmlxplat_i2c_main_init()cleanup flow if this device was successfully registered.Fixes 158cd8320776 ("platform: mellanox: Split logic in init and exit flow")Reported-by Christophe JAILLET <[email protected]>Signed-off-by Vadim Pasternak <[email protected]>--- drivers/platform/x86/mlx-platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/platform/x86/mlx-platform.c +3
-1@@ -6514,6 +6514,7 @@ static int mlxplat_i2c_main_init(struct mlxplat_priv *priv)return 0 ; fail_mlxplat_i2c_mux_topology_init: +platform_device_unregister (priv->pdev_i2c); fail_platform_i2c_register: fail_mlxplat_mlxcpld_verify_bus_topology:return err;@@ -6521,6 +6522,7 @@ static int mlxplat_i2c_main_init(struct mlxplat_priv *priv)static void mlxplat_i2c_main_exit (struct mlxplat_priv *priv) { +mlxplat_pre_exit (priv);mlxplat_i2c_mux_topology_exit (priv);if (priv->pdev_i2c)platform_device_unregister (priv->pdev_i2c);@@ -6597,7 +6599,7 @@ static int mlxplat_probe(struct platform_device *pdev) fail_register_reboot_notifier: fail_regcache_sync: -mlxplat_pre_exit (priv); +mlxplat_i2c_main_exit (priv); fail_mlxplat_i2c_main_init: fail_regmap_write: fail_alloc:
drivers/platform/x86/mlx-platform.c static int mlxplat_remove(struct platform_device *pdev) · line 6621
Quoted 7 lines
drivers/platform/x86/mlx-platform.c +0
-1@@ -6614,7 +6616,6 @@ static int mlxplat_remove(struct platform_device *pdev) pm_power_off =NULL ;if (mlxplat_reboot_nb)unregister_reboot_notifier (mlxplat_reboot_nb); -mlxplat_pre_exit (priv);mlxplat_i2c_main_exit (priv);mlxplat_post_exit ();return 0 ;
Thanks,
Signature · 1 line
i.
PATCH 2/3 platform: mellanox: Fix misspelling error in routine name
In reply to Vadim PasternakChange mlxplat_i2c_main_complition_notify() tomlxplat_i2c_main_completion_notify().
--- drivers/platform/x86/mlx-platform.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/mlx-platform.c +4 -4
@@ -368,7 +368,7 @@ struct mlxplat_priv { };static struct platform_device *mlxplat_dev; -static int mlxplat_i2c_main_complition_notify (void *handle,int id); +static int mlxplat_i2c_main_completion_notify (void *handle,int id);static void __iomem *i2c_bridge_addr, *jtag_bridge_addr;/* Regions for LPC I2C controller and LPC base register space */
@@ -384,7 +384,7 @@ static const struct resource mlxplat_lpc_resources[] = {/* Platform systems default i2c data */ static struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_i2c_default_data = { - .completion_notify = mlxplat_i2c_main_complition_notify, + .completion_notify = mlxplat_i2c_main_completion_notify, };/* Platform i2c next generation systems data */
@@ -409,7 +409,7 @@ static struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_i2c_ng_data = { .mask = MLXPLAT_CPLD_AGGR_MASK_COMEX, .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRCO_OFFSET, .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_I2C, - .completion_notify = mlxplat_i2c_main_complition_notify, + .completion_notify = mlxplat_i2c_main_completion_notify, };/* Platform default channels */
@@ -6471,7 +6471,7 @@ static void mlxplat_i2c_mux_topology_exit(struct mlxplat_priv *priv) } } -static int mlxplat_i2c_main_complition_notify (void *handle,int id) +static int mlxplat_i2c_main_completion_notify (void *handle,int id) {struct mlxplat_priv *priv = handle;
Signature · 1 line
2.20.1
PATCH 3/3 platform: mellanox: Rename some init()/exit() functions for consistent naming
In reply to Vadim PasternakCurrently some names of init()/exit() pairing function are not consistent.
Rename pair mlxplat_pre_init()/mlxplat_post_exit() to respectively mlxplat_logicdev_init()/mlxplat_logicdev_exit().
Rename pair mlxplat_post_init()/mlxplat_pre_exit() to respectively mlxplat_platdevs_init()/mlxplat_platdevs_exit().
--- drivers/platform/x86/mlx-platform.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/platform/x86/mlx-platform.c +9 -9
@@ -6291,7 +6291,7 @@ static void mlxplat_pci_fpga_devices_exit(void) }static int -mlxplat_pre_init (struct resource **hotplug_resources,unsigned int *hotplug_resources_size) +mlxplat_logicdev_init (struct resource **hotplug_resources,unsigned int *hotplug_resources_size) {int err;
@@ -6302,7 +6302,7 @@ mlxplat_pre_init(struct resource **hotplug_resources, unsigned int *hotplug_resoreturn err; } -static void mlxplat_post_exit (void ) +static void mlxplat_logicdev_exit (void ) {if (lpc_bridge)mlxplat_pci_fpga_devices_exit ();
@@ -6310,7 +6310,7 @@ static void mlxplat_post_exit(void)mlxplat_lpc_cpld_device_exit (); } -static int mlxplat_post_init (struct mlxplat_priv *priv) +static int mlxplat_platdevs_init (struct mlxplat_priv *priv) {int i =0 , err;
@@ -6407,7 +6407,7 @@ static int mlxplat_post_init(struct mlxplat_priv *priv)return err; } -static void mlxplat_pre_exit (struct mlxplat_priv *priv) +static void mlxplat_platdevs_exit (struct mlxplat_priv *priv) {int i;
@@ -6429,7 +6429,7 @@ mlxplat_i2c_mux_complition_notify(void *handle, struct i2c_adapter *parent, {struct mlxplat_priv *priv = handle; -return mlxplat_post_init (priv); +return mlxplat_platdevs_init (priv); }static int mlxplat_i2c_mux_topology_init (struct mlxplat_priv *priv)
@@ -6522,7 +6522,7 @@ static int mlxplat_i2c_main_init(struct mlxplat_priv *priv)static void mlxplat_i2c_main_exit (struct mlxplat_priv *priv) { -mlxplat_pre_exit (priv); +mlxplat_platdevs_exit (priv);mlxplat_i2c_mux_topology_exit (priv);if (priv->pdev_i2c)platform_device_unregister (priv->pdev_i2c);
@@ -6544,7 +6544,7 @@ static int mlxplat_probe(struct platform_device *pdev) mlxplat_dev = pdev; } - err =mlxplat_pre_init (&hotplug_resources, &hotplug_resources_size); + err =mlxplat_logicdev_init (&hotplug_resources, &hotplug_resources_size);if (err)return err;
@@ -6603,7 +6603,7 @@ static int mlxplat_probe(struct platform_device *pdev) fail_mlxplat_i2c_main_init: fail_regmap_write: fail_alloc: -mlxplat_post_exit (); +mlxplat_logicdev_exit ();return err; }
@@ -6617,7 +6617,7 @@ static int mlxplat_remove(struct platform_device *pdev)if (mlxplat_reboot_nb)unregister_reboot_notifier (mlxplat_reboot_nb);mlxplat_i2c_main_exit (priv); -mlxplat_post_exit (); +mlxplat_logicdev_exit ();return 0 ; }
Signature · 1 line
2.20.1
Ilpo Järvinen
maintainerQuoted 8 lines · Vadim Pasternak
The patchset:
- Fixes memory leak in error handling flow.
- Add cosmetic changes - misspelling fix, better naming/Patches #1: Fixes memory leak issue.
Patch #2: Fix misspelling.
Patches #3: Renames few routines for better naming convention.
Quoted 6 lines
Vadim Pasternak (3):
platform: mellanox: Fix a resource leak in an error handling path in
probing flow
platform: mellanox: Fix misspelling error in routine name
platform: mellanox: Rename some init()/exit() functions for consistent
naming
Thanks for the patches. I've applied these into platform-drivers-x86-mellanox-init branch and merged that into review-ilpo. (I decided to reorder the patches 2 and 3 though as it felt more logical ordering.)
Signature · 1 line
i.