fbdev: n411: check return value
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Tue, 23 Feb 2016 12:44:17 +0000 (18:14 +0530)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 26 Feb 2016 10:16:58 +0000 (12:16 +0200)
We were not checking the return value of platform_device_add_data()
which can fail.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/fbdev/n411.c

index 935830fea7b62f3eb47564b38917e67545c1febb..053deacad7cc12d3415e7e5d3b6c0b55e91e22ea 100644 (file)
@@ -165,16 +165,22 @@ static int __init n411_init(void)
        if (!n411_device)
                return -ENOMEM;
 
-       platform_device_add_data(n411_device, &n411_board, sizeof(n411_board));
+       ret = platform_device_add_data(n411_device, &n411_board,
+                                      sizeof(n411_board));
+       if (ret)
+               goto put_plat_device;
 
        /* this _add binds hecubafb to n411. hecubafb refcounts n411 */
        ret = platform_device_add(n411_device);
 
        if (ret)
-               platform_device_put(n411_device);
+               goto put_plat_device;
 
-       return ret;
+       return 0;
 
+put_plat_device:
+       platform_device_put(n411_device);
+       return ret;
 }
 
 static void __exit n411_exit(void)