From: Libo Chen <clbchenlibo.chen@huawei.com>
To: <dwmw2@infradead.org>, Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Li Zefan" <lizefan@huawei.com>,
artem.bityutskiy@linux.intel.com,
"Rafał Miłecki" <zajec5@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
"Bill Pemberton" <wfp5p@virginia.edu>,
linux-mtd@lists.infradead.org, hauke@hauke-m.de
Subject: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
Date: Thu, 30 May 2013 10:22:12 +0800 [thread overview]
Message-ID: <51A6B7D4.7040202@huawei.com> (raw)
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
WARNING: multiple messages have this Message-ID (diff)
From: Libo Chen <clbchenlibo.chen@huawei.com>
To: <dwmw2@infradead.org>, Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Rafał Miłecki" <zajec5@gmail.com>,
artem.bityutskiy@linux.intel.com,
"Bill Pemberton" <wfp5p@virginia.edu>,
hauke@hauke-m.de, linux-mtd@lists.infradead.org,
LKML <linux-kernel@vger.kernel.org>,
"Li Zefan" <lizefan@huawei.com>
Subject: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access
Date: Thu, 30 May 2013 10:22:12 +0800 [thread overview]
Message-ID: <51A6B7D4.7040202@huawei.com> (raw)
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
next reply other threads:[~2013-05-30 2:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 2:22 Libo Chen [this message]
2013-05-30 2:22 ` [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access 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
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=51A6B7D4.7040202@huawei.com \
--to=clbchenlibo.chen@huawei.com \
--cc=andy.shevchenko@gmail.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=hauke@hauke-m.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lizefan@huawei.com \
--cc=wfp5p@virginia.edu \
--cc=zajec5@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 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.