* [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
@ 2013-05-30 2:22 ` Libo Chen
0 siblings, 0 replies; 8+ messages in thread
From: Libo Chen @ 2013-05-30 2:22 UTC (permalink / raw)
To: dwmw2, Andy Shevchenko
Cc: Rafał Miłecki, artem.bityutskiy, Bill Pemberton, hauke,
linux-mtd, LKML, Li Zefan
mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
So I use devm_kazlloc instead of kazlloc to avoid it.
* Changelog:
convert to devm_kzalloc
Signed-off-by: Libo chen <libo.chen@huawei.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/mtd/devices/bcm47xxsflash.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 18e7761..2630d5c 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -54,11 +54,9 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
struct bcm47xxsflash *b47s;
int err;
- b47s = kzalloc(sizeof(*b47s), GFP_KERNEL);
- if (!b47s) {
- err = -ENOMEM;
- goto out;
- }
+ b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL);
+ if (!b47s)
+ return -ENOMEM;
sflash->priv = b47s;
b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
@@ -81,15 +79,10 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
if (err) {
pr_err("Failed to register MTD device: %d\n", err);
- goto err_dev_reg;
+ return err;
}
return 0;
-
-err_dev_reg:
- kfree(&b47s->mtd);
-out:
- return err;
}
static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
@@ -98,7 +91,6 @@ static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
struct bcm47xxsflash *b47s = sflash->priv;
mtd_device_unregister(&b47s->mtd);
- kfree(b47s);
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
@ 2013-05-30 2:22 ` Libo Chen
0 siblings, 0 replies; 8+ messages in thread
From: Libo Chen @ 2013-05-30 2:22 UTC (permalink / raw)
To: dwmw2, Andy Shevchenko
Cc: Li Zefan, artem.bityutskiy, Rafał Miłecki, LKML,
Bill Pemberton, linux-mtd, hauke
mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
So I use devm_kazlloc instead of kazlloc to avoid it.
* Changelog:
convert to devm_kzalloc
Signed-off-by: Libo chen <libo.chen@huawei.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/mtd/devices/bcm47xxsflash.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 18e7761..2630d5c 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -54,11 +54,9 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
struct bcm47xxsflash *b47s;
int err;
- b47s = kzalloc(sizeof(*b47s), GFP_KERNEL);
- if (!b47s) {
- err = -ENOMEM;
- goto out;
- }
+ b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL);
+ if (!b47s)
+ return -ENOMEM;
sflash->priv = b47s;
b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
@@ -81,15 +79,10 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
if (err) {
pr_err("Failed to register MTD device: %d\n", err);
- goto err_dev_reg;
+ return err;
}
return 0;
-
-err_dev_reg:
- kfree(&b47s->mtd);
-out:
- return err;
}
static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
@@ -98,7 +91,6 @@ static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
struct bcm47xxsflash *b47s = sflash->priv;
mtd_device_unregister(&b47s->mtd);
- kfree(b47s);
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
2013-05-30 2:22 ` Libo Chen
@ 2013-05-30 10:26 ` Andy Shevchenko
-1 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-05-30 10:26 UTC (permalink / raw)
To: Libo Chen
Cc: dwmw2, Rafał Miłecki, artem.bityutskiy, Bill Pemberton,
hauke, linux-mtd, LKML, Li Zefan
On Thu, May 30, 2013 at 5:22 AM, Libo Chen <clbchenlibo.chen@huawei.com> wrote:
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
> So I use devm_kazlloc instead of kazlloc to avoid it.
You may amend commit message, but technically you have my
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
> index 18e7761..2630d5c 100644
> --- a/drivers/mtd/devices/bcm47xxsflash.c
> +++ b/drivers/mtd/devices/bcm47xxsflash.c
> @@ -54,11 +54,9 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
> struct bcm47xxsflash *b47s;
> int err;
>
> - b47s = kzalloc(sizeof(*b47s), GFP_KERNEL);
> - if (!b47s) {
> - err = -ENOMEM;
> - goto out;
> - }
> + b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL);
> + if (!b47s)
> + return -ENOMEM;
> sflash->priv = b47s;
>
> b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
> @@ -81,15 +79,10 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
> err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
> if (err) {
> pr_err("Failed to register MTD device: %d\n", err);
> - goto err_dev_reg;
> + return err;
> }
>
> return 0;
> -
> -err_dev_reg:
> - kfree(&b47s->mtd);
> -out:
> - return err;
> }
>
> static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
> @@ -98,7 +91,6 @@ static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
> struct bcm47xxsflash *b47s = sflash->priv;
>
> mtd_device_unregister(&b47s->mtd);
> - kfree(b47s);
>
> return 0;
> }
> --
> 1.7.1
>
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
@ 2013-05-30 10:26 ` Andy Shevchenko
0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2013-05-30 10:26 UTC (permalink / raw)
To: Libo Chen
Cc: Li Zefan, artem.bityutskiy, Rafał Miłecki, LKML,
Bill Pemberton, linux-mtd, hauke, dwmw2
On Thu, May 30, 2013 at 5:22 AM, Libo Chen <clbchenlibo.chen@huawei.com> wrote:
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
> So I use devm_kazlloc instead of kazlloc to avoid it.
You may amend commit message, but technically you have my
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
> index 18e7761..2630d5c 100644
> --- a/drivers/mtd/devices/bcm47xxsflash.c
> +++ b/drivers/mtd/devices/bcm47xxsflash.c
> @@ -54,11 +54,9 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
> struct bcm47xxsflash *b47s;
> int err;
>
> - b47s = kzalloc(sizeof(*b47s), GFP_KERNEL);
> - if (!b47s) {
> - err = -ENOMEM;
> - goto out;
> - }
> + b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL);
> + if (!b47s)
> + return -ENOMEM;
> sflash->priv = b47s;
>
> b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
> @@ -81,15 +79,10 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
> err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
> if (err) {
> pr_err("Failed to register MTD device: %d\n", err);
> - goto err_dev_reg;
> + return err;
> }
>
> return 0;
> -
> -err_dev_reg:
> - kfree(&b47s->mtd);
> -out:
> - return err;
> }
>
> static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
> @@ -98,7 +91,6 @@ static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
> struct bcm47xxsflash *b47s = sflash->priv;
>
> mtd_device_unregister(&b47s->mtd);
> - kfree(b47s);
>
> return 0;
> }
> --
> 1.7.1
>
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
2013-05-30 2:22 ` Libo Chen
@ 2013-05-31 7:57 ` Rafał Miłecki
-1 siblings, 0 replies; 8+ messages in thread
From: Rafał Miłecki @ 2013-05-31 7:57 UTC (permalink / raw)
To: Libo Chen
Cc: dwmw2, Andy Shevchenko, artem.bityutskiy, Bill Pemberton, hauke,
linux-mtd, LKML, Li Zefan
2013/5/30 Libo Chen <clbchenlibo.chen@huawei.com>:
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
> So I use devm_kazlloc instead of kazlloc to avoid it.
I think you should use
mtd: bcm47xxsflash:
prefix for both patches, but Artem or David may want to comment on that.
Nice trick with that devm_kzalloc, I didn't know it.
--
Rafał
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
@ 2013-05-31 7:57 ` Rafał Miłecki
0 siblings, 0 replies; 8+ messages in thread
From: Rafał Miłecki @ 2013-05-31 7:57 UTC (permalink / raw)
To: Libo Chen
Cc: Li Zefan, artem.bityutskiy, LKML, Andy Shevchenko,
Bill Pemberton, linux-mtd, hauke, dwmw2
2013/5/30 Libo Chen <clbchenlibo.chen@huawei.com>:
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
> So I use devm_kazlloc instead of kazlloc to avoid it.
I think you should use
mtd: bcm47xxsflash:
prefix for both patches, but Artem or David may want to comment on that.
Nice trick with that devm_kzalloc, I didn't know it.
--
Rafał
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
2013-05-30 2:22 ` Libo Chen
@ 2013-08-22 19:39 ` Brian Norris
-1 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2013-08-22 19:39 UTC (permalink / raw)
To: Libo Chen
Cc: dwmw2, Andy Shevchenko, Li Zefan, artem.bityutskiy,
Rafał Miłecki, LKML, Bill Pemberton, linux-mtd, hauke
On Thu, May 30, 2013 at 10:22:12AM +0800, Libo Chen wrote:
>
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
> So I use devm_kazlloc instead of kazlloc to avoid it.
>
> * Changelog:
> convert to devm_kzalloc
>
> Signed-off-by: Libo chen <libo.chen@huawei.com>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Resolved a conflict and pushed to l2-mtd.git. Thanks!
Brian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
@ 2013-08-22 19:39 ` Brian Norris
0 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2013-08-22 19:39 UTC (permalink / raw)
To: Libo Chen
Cc: Bill Pemberton, artem.bityutskiy, Rafał Miłecki, LKML,
Andy Shevchenko, Li Zefan, linux-mtd, hauke, dwmw2
On Thu, May 30, 2013 at 10:22:12AM +0800, Libo Chen wrote:
>
> mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member.
> So I use devm_kazlloc instead of kazlloc to avoid it.
>
> * Changelog:
> convert to devm_kzalloc
>
> Signed-off-by: Libo chen <libo.chen@huawei.com>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Resolved a conflict and pushed to l2-mtd.git. Thanks!
Brian
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-08-22 19:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30 2:22 [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access Libo Chen
2013-05-30 2:22 ` Libo Chen
2013-05-30 10:26 ` Andy Shevchenko
2013-05-30 10:26 ` Andy Shevchenko
2013-05-31 7:57 ` Rafał Miłecki
2013-05-31 7:57 ` Rafał Miłecki
2013-08-22 19:39 ` Brian Norris
2013-08-22 19:39 ` Brian Norris
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.