Patchwork [RESEND] mtd: fix kfree bcm47xxsflash

login
register
mail settings
Submitter Libo Chen
Date May 22, 2013, 3:51 a.m.
Message ID <519C40A8.1070506@huawei.com>
Download mbox | patch
Permalink /patch/245501/
State New
Headers show

Comments

Libo Chen - May 22, 2013, 3:51 a.m.
mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash  not its member.

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Acked-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/mtd/devices/bcm47xxsflash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

* add Acked-by: Rafał Miłecki <zajec5@gmail.com>
* change send list
Rafał Miłecki - May 22, 2013, 5:32 a.m.
2013/5/22 Libo Chen <clbchenlibo.chen@huawei.com>:
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash  not its member.

Thanks!
Libo Chen - May 28, 2013, 12:40 p.m.
ping...

On 2013/5/22 11:51, Libo Chen wrote:
> 
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash  not its member.
> 
> Signed-off-by: Libo Chen <libo.chen@huawei.com>
> Acked-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>  drivers/mtd/devices/bcm47xxsflash.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> * add Acked-by: Rafał Miłecki <zajec5@gmail.com>
> * change send list
> 
> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
> index 9526628..4aa9141 100644
> --- a/drivers/mtd/devices/bcm47xxsflash.c
> +++ b/drivers/mtd/devices/bcm47xxsflash.c
> @@ -76,7 +76,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
>  	return 0;
> 
>  err_dev_reg:
> -	kfree(&b47s->mtd);
> +	kfree(b47s);
>  out:
>  	return err;
>  }
>
Rafał Miłecki - May 28, 2013, 12:49 p.m.
2013/5/28 Libo Chen <clbchenlibo.chen@huawei.com>:
> ping...

It takes a lot of time for someone to pick up mtd patches, just be patient ;)
Andy Shevchenko - May 28, 2013, 3:29 p.m.
This is good fix, but I rather prefer not to see it in this shape.
See comments below.

On Wed, May 22, 2013 at 6:51 AM, Libo Chen <clbchenlibo.chen@huawei.com> wrote:
>
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash  not its member.
>
> Signed-off-by: Libo Chen <libo.chen@huawei.com>
> Acked-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>  drivers/mtd/devices/bcm47xxsflash.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> * add Acked-by: Rafał Miłecki <zajec5@gmail.com>
> * change send list
>
> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
> index 9526628..4aa9141 100644
> --- a/drivers/mtd/devices/bcm47xxsflash.c
> +++ b/drivers/mtd/devices/bcm47xxsflash.c
> @@ -76,7 +76,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
>         return 0;
>
>  err_dev_reg:
> -       kfree(&b47s->mtd);
> +       kfree(b47s);
>  out:
>         return err;
>  }

What about to switch to devm_* and remove those labels and kfrees at all?

Additionally you can add another patch to use module_platform_driver()
macro instead of module_init/exit.

--
With Best Regards,
Andy Shevchenko
Libo Chen - May 29, 2013, 2:40 a.m.
On 2013/5/28 23:29, Andy Shevchenko wrote:
> This is good fix, but I rather prefer not to see it in this shape.
> See comments below.
> 
> On Wed, May 22, 2013 at 6:51 AM, Libo Chen <clbchenlibo.chen@huawei.com> wrote:
>>
>> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash  not its member.
>>
>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>> Acked-by: Rafał Miłecki <zajec5@gmail.com>
>> ---
>>  drivers/mtd/devices/bcm47xxsflash.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> * add Acked-by: Rafał Miłecki <zajec5@gmail.com>
>> * change send list
>>
>> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
>> index 9526628..4aa9141 100644
>> --- a/drivers/mtd/devices/bcm47xxsflash.c
>> +++ b/drivers/mtd/devices/bcm47xxsflash.c
>> @@ -76,7 +76,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
>>         return 0;
>>
>>  err_dev_reg:
>> -       kfree(&b47s->mtd);
>> +       kfree(b47s);
>>  out:
>>         return err;
>>  }
> 
> What about to switch to devm_* and remove those labels and kfrees at all?
> 
> Additionally you can add another patch to use module_platform_driver()
> macro instead of module_init/exit.
> 

ok, I will update later.

thanks,

Libo


> --
> With Best Regards,
> Andy Shevchenko
> 
> .
>

Patch

diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 9526628..4aa9141 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -76,7 +76,7 @@  static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	return 0;

 err_dev_reg:
-	kfree(&b47s->mtd);
+	kfree(b47s);
 out:
 	return err;
 }