video: fbdev: pxafb: handle errors from pxafb_init_fbinfo() correctly
authorDaniel Mack <daniel@zonque.org>
Tue, 24 Jul 2018 17:11:25 +0000 (19:11 +0200)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Tue, 24 Jul 2018 17:11:25 +0000 (19:11 +0200)
pxafb_init_fbinfo() can not only report errors caused by failed
allocations but also when the clock can't be found.

To fix this, return an error pointer instead of NULL in case of errors,
and up-chain the result.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
drivers/video/fbdev/pxafb.c

index 6f3a93b3097c2b9c35892e2d72b3532d9b6f2683..68459b07d44253c7a61b348cd952a4dae8aece4a 100644 (file)
@@ -1802,14 +1802,14 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev,
        fbi = devm_kzalloc(dev, sizeof(struct pxafb_info) + sizeof(u32) * 16,
                           GFP_KERNEL);
        if (!fbi)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        fbi->dev = dev;
        fbi->inf = inf;
 
        fbi->clk = devm_clk_get(dev, NULL);
        if (IS_ERR(fbi->clk))
-               return NULL;
+               return ERR_CAST(fbi->clk);
 
        strcpy(fbi->fb.fix.id, PXA_NAME);
 
@@ -2287,10 +2287,9 @@ static int pxafb_probe(struct platform_device *dev)
        }
 
        fbi = pxafb_init_fbinfo(&dev->dev, inf);
-       if (!fbi) {
-               /* only reason for pxafb_init_fbinfo to fail is kmalloc */
+       if (IS_ERR(fbi)) {
                dev_err(&dev->dev, "Failed to initialize framebuffer device\n");
-               ret = -ENOMEM;
+               ret = PTR_ERR(fbi);
                goto failed;
        }