Re: [PATCH] mmc/core: free mmc_card when cmd 3, 9, 7 got failed in mmc_sd_init_card

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 17, 2013 at 02:21:10PM +0800, wei_wang@xxxxxxxxxxxxxx wrote:
> From: Wei WANG <wei_wang@xxxxxxxxxxxxxx>
> 
> In function mmc_sd_init_card, if command 3/9/7 got failed, mmc_card
> allocated just before won't be freed. This would cause memory leak.
> 
> Signed-off-by: Wei WANG <wei_wang@xxxxxxxxxxxxxx>
> ---
>  drivers/mmc/core/sd.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 176d125..1240a85 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -942,13 +942,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
>  	if (!mmc_host_is_spi(host)) {
>  		err = mmc_send_relative_addr(host, &card->rca);
>  		if (err)
> -			return err;
> +			goto free_card;
>  	}
>  
>  	if (!oldcard) {
>  		err = mmc_sd_get_csd(host, card);
>  		if (err)
> -			return err;
> +			goto free_card;
>  
>  		mmc_decode_cid(card);
>  	}
> @@ -959,7 +959,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
>  	if (!mmc_host_is_spi(host)) {
>  		err = mmc_select_card(card);
>  		if (err)
> -			return err;
> +			goto free_card;
>  	}
>  
>  	err = mmc_sd_setup_card(host, card, oldcard != NULL);
> -- 
> 1.7.9.5
> 
> _______________________________________________
> devel mailing list
> devel@xxxxxxxxxxxxxxxxxxxxxx
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

I see that mmc_release_host is called in function mmc_sd_resume if
mmc_sd_init_card fails and then again in mmc_sd_runtime_resume which
calls mmc_sd_resume. A bug ?
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux