diff mbox

[1/6] mtd: r852: Fix device_create_file() usage

Message ID 1433193054-26865-2-git-send-email-richard@nod.at
State Accepted
Commit 905cce7f4309f3ec19c1ed67edd68b7e67e88f3e
Headers show

Commit Message

Richard Weinberger June 1, 2015, 9:10 p.m. UTC
device_create_file() can fail, therefore we have to
handle this case and abort.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/nand/r852.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Brian Norris June 17, 2015, 2:07 a.m. UTC | #1
On Mon, Jun 01, 2015 at 11:10:49PM +0200, Richard Weinberger wrote:
> device_create_file() can fail, therefore we have to
> handle this case and abort.
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>

Pushed the first 5. Still looking at the 6th.
diff mbox

Patch

diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index baea83f..77e96d2 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
@@ -653,11 +653,15 @@  static int r852_register_nand_device(struct r852_device *dev)
 	if (sm_register_device(dev->mtd, dev->sm))
 		goto error2;
 
-	if (device_create_file(&dev->mtd->dev, &dev_attr_media_type))
+	if (device_create_file(&dev->mtd->dev, &dev_attr_media_type)) {
 		message("can't create media type sysfs attribute");
+		goto error3;
+	}
 
 	dev->card_registred = 1;
 	return 0;
+error3:
+	nand_release(dev->mtd);
 error2:
 	kfree(dev->mtd);
 error1: