mtd: maps: physmap: Check mtd_device_{parse_register, unregister}() ret code
authorBoris Brezillon <boris.brezillon@bootlin.com>
Fri, 19 Oct 2018 07:49:00 +0000 (09:49 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Mon, 5 Nov 2018 21:24:05 +0000 (22:24 +0100)
mtd_device_parse_register() and mtd_device_unregister() can fail,
check their return code and propagate the error to the upper layer
if needed.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
drivers/mtd/maps/physmap.c

index 86679d149a491eefd30563db0937937a104a45b2..9b34223c4635561d766a75966735bb4d92b771b3 100644 (file)
@@ -35,7 +35,7 @@ static int physmap_flash_remove(struct platform_device *dev)
 {
        struct physmap_flash_info *info;
        struct physmap_flash_data *physmap_data;
-       int i;
+       int i, err;
 
        info = platform_get_drvdata(dev);
        if (info == NULL)
@@ -44,7 +44,10 @@ static int physmap_flash_remove(struct platform_device *dev)
        physmap_data = dev_get_platdata(&dev->dev);
 
        if (info->cmtd) {
-               mtd_device_unregister(info->cmtd);
+               err = mtd_device_unregister(info->cmtd);
+               if (err)
+                       return err;
+
                if (info->cmtd != info->mtds[0])
                        mtd_concat_destroy(info->cmtd);
        }
@@ -194,8 +197,12 @@ static int physmap_flash_probe(struct platform_device *dev)
 
        part_types = physmap_data->part_probe_types ? : part_probe_types;
 
-       mtd_device_parse_register(info->cmtd, part_types, NULL,
-                                 physmap_data->parts, physmap_data->nr_parts);
+       err = mtd_device_parse_register(info->cmtd, part_types, NULL,
+                                       physmap_data->parts,
+                                       physmap_data->nr_parts);
+       if (err)
+               goto err_out;
+
        return 0;
 
 err_out: