lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 30 May 2013 10:22:12 +0800
From:	Libo Chen <clbchenlibo.chen@...wei.com>
To:	<dwmw2@...radead.org>, Andy Shevchenko <andy.shevchenko@...il.com>
CC:	Rafał Miłecki <zajec5@...il.com>,
	<artem.bityutskiy@...ux.intel.com>,
	Bill Pemberton <wfp5p@...ginia.edu>, <hauke@...ke-m.de>,
	<linux-mtd@...ts.infradead.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Li Zefan <lizefan@...wei.com>
Subject: [PATCH RESEND 1/2] mtd: bcm47: convert kzalloc to avoid invalid access


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@...wei.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@...il.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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ