stifb: check fb_alloc_cmap return value and handle failure properly
authorAndres Salomon <dilinger@queued.net>
Tue, 31 Mar 2009 22:25:26 +0000 (15:25 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Apr 2009 15:59:31 +0000 (08:59 -0700)
Signed-off-by: Andres Salomon <dilinger@debian.org>
Acked-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/stifb.c

index 1664814..eabaad7 100644 (file)
@@ -1262,24 +1262,25 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
        info->flags = FBINFO_DEFAULT;
        info->pseudo_palette = &fb->pseudo_palette;
 
-       /* This has to been done !!! */
-       fb_alloc_cmap(&info->cmap, NR_PALETTE, 0);
+       /* This has to be done !!! */
+       if (fb_alloc_cmap(&info->cmap, NR_PALETTE, 0))
+               goto out_err1;
        stifb_init_display(fb);
 
        if (!request_mem_region(fix->smem_start, fix->smem_len, "stifb fb")) {
                printk(KERN_ERR "stifb: cannot reserve fb region 0x%04lx-0x%04lx\n",
                                fix->smem_start, fix->smem_start+fix->smem_len);
-               goto out_err1;
+               goto out_err2;
        }
                
        if (!request_mem_region(fix->mmio_start, fix->mmio_len, "stifb mmio")) {
                printk(KERN_ERR "stifb: cannot reserve sti mmio region 0x%04lx-0x%04lx\n",
                                fix->mmio_start, fix->mmio_start+fix->mmio_len);
-               goto out_err2;
+               goto out_err3;
        }
 
        if (register_framebuffer(&fb->info) < 0)
-               goto out_err3;
+               goto out_err4;
 
        sti->info = info; /* save for unregister_framebuffer() */
 
@@ -1297,13 +1298,14 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
        return 0;
 
 
-out_err3:
+out_err4:
        release_mem_region(fix->mmio_start, fix->mmio_len);
-out_err2:
+out_err3:
        release_mem_region(fix->smem_start, fix->smem_len);
+out_err2:
+       fb_dealloc_cmap(&info->cmap);
 out_err1:
        iounmap(info->screen_base);
-       fb_dealloc_cmap(&info->cmap);
 out_err0:
        kfree(fb);
        return -ENXIO;