mtd: r852: Fix device_create_file() usage
authorRichard Weinberger <richard@nod.at>
Mon, 1 Jun 2015 21:10:49 +0000 (23:10 +0200)
committerBrian Norris <computersforpeace@gmail.com>
Wed, 17 Jun 2015 01:58:46 +0000 (18:58 -0700)
device_create_file() can fail, therefore we have to
handle this case and abort.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/r852.c

index baea83f4dea84f0f0f3d9917e1797b47cb262fca..77e96d2df96cac12194dc0679dfac1dceb098d5e 100644 (file)
@@ -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: