X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Vadim Pasternak <vadimp@nvidia.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	christophe.jaillet@wanadoo.fr,
	platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH platform 1/3] platform: mellanox: Fix a resource leak in an error handling path in probing flow
Date: Fri, 6 Oct 2023 16:30:07 +0300 (EEST)	[thread overview]
Message-ID: <fe3cba6e-6a50-8f51-552d-2d76344813da@linux.intel.com> (raw)
In-Reply-To: <20231005075616.42777-2-vadimp@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2450 bytes --]

On Thu, 5 Oct 2023, Vadim Pasternak wrote:

> 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: 158cd8320776 ("platform: mellanox: Split logic in init and exit flow")
> Reported-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Closes: https://lore.kernel.org/lkml/70165032-796e-6f5c-6748-f514e3b9d08c@linux.intel.com/T/
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
> ---
>  drivers/platform/x86/mlx-platform.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
> index 3d96dbf79a72..a2ffe4157df1 100644
> --- a/drivers/platform/x86/mlx-platform.c
> +++ b/drivers/platform/x86/mlx-platform.c
> @@ -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;
> 

Thanks,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

  reply	other threads:[~2023-10-06 13:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05  7:56 [PATCH platform 0/3] platform/x86: Add fixes and amendments for init()/exit() flows Vadim Pasternak
2023-10-05  7:56 ` [PATCH platform 1/3] platform: mellanox: Fix a resource leak in an error handling path in probing flow Vadim Pasternak
2023-10-06 13:30   ` Ilpo Järvinen [this message]
2023-10-05  7:56 ` [PATCH platform 2/3] platform: mellanox: Fix misspelling error in routine name Vadim Pasternak
2023-10-05  7:56 ` [PATCH platform 3/3] platform: mellanox: Rename some init()/exit() functions for consistent naming Vadim Pasternak
2023-10-06 14:55 ` [PATCH platform 0/3] platform/x86: Add fixes and amendments for init()/exit() flows Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe3cba6e-6a50-8f51-552d-2d76344813da@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hdegoede@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=vadimp@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox