public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	ulf.hansson@linaro.org, orsonzhai@gmail.com,
	baolin.wang7@gmail.com, zhang.lyra@gmail.com
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mmc: sdhci-sprd: Fix some resource leaks in the remove function
Date: Tue, 5 Jan 2021 14:39:52 +0200	[thread overview]
Message-ID: <1cfeeb62-8211-4a2a-0cf5-c3799d7ef42e@intel.com> (raw)
In-Reply-To: <20201217204236.163446-1-christophe.jaillet@wanadoo.fr>

On 17/12/20 10:42 pm, Christophe JAILLET wrote:
> 'sdhci_remove_host()' and 'sdhci_pltfm_free()' should be used in place of
> 'mmc_remove_host()' and 'mmc_free_host()'.
> 
> This avoids some resource leaks, is more in line with the error handling
> path of the probe function, and is more consistent with other drivers.
> 
> Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Other adjustment may be needed.
> I'm not sure at all of the 0 passed to 'sdhci_remove_host()'. Some drivers
> pass 0, some have some more complicated computation.

'0' means cleanup nicely. '1' (dead) means nothing works anymore, including
interrupts, so give up on requests immediately.

Either should work.  '0' is better unless your host controller really is
dead, which is mostly not possible except for some legacy PCI devices.

> ---
>  drivers/mmc/host/sdhci-sprd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index f85171edabeb..5dc36efff47f 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -708,14 +708,14 @@ static int sdhci_sprd_remove(struct platform_device *pdev)
>  {
>  	struct sdhci_host *host = platform_get_drvdata(pdev);
>  	struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
> -	struct mmc_host *mmc = host->mmc;
>  
> -	mmc_remove_host(mmc);
> +	sdhci_remove_host(host, 0);
> +
>  	clk_disable_unprepare(sprd_host->clk_sdio);
>  	clk_disable_unprepare(sprd_host->clk_enable);
>  	clk_disable_unprepare(sprd_host->clk_2x_enable);
>  
> -	mmc_free_host(mmc);
> +	sdhci_pltfm_free(pdev);
>  
>  	return 0;
>  }
> 


  parent reply	other threads:[~2021-01-05 12:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 20:42 [PATCH] mmc: sdhci-sprd: Fix some resource leaks in the remove function Christophe JAILLET
2020-12-17 22:55 ` Orson Zhai
2020-12-18 13:46   ` Christophe JAILLET
2020-12-20  2:05     ` Orson Zhai
2021-01-05 12:39 ` Adrian Hunter [this message]
2021-01-11 18:05 ` Ulf Hansson

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=1cfeeb62-8211-4a2a-0cf5-c3799d7ef42e@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=baolin.wang7@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=zhang.lyra@gmail.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