]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
valkyriefb: 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/valkyriefb.c

index 7b0cef9ca8f98d52fcc927050204f1ec874194b8..4bb9a0b18950028b21546eb443ac9f215bf97f8e 100644 (file)
@@ -119,7 +119,7 @@ static void set_valkyrie_clock(unsigned char *params);
 static int valkyrie_var_to_par(struct fb_var_screeninfo *var,
        struct fb_par_valkyrie *par, const struct fb_info *fb_info);
 
-static void valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p);
+static int valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p);
 static void valkyrie_par_to_fix(struct fb_par_valkyrie *par, struct fb_fix_screeninfo *fix);
 static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p);
 
@@ -381,18 +381,22 @@ int __init valkyriefb_init(void)
 
        valkyrie_choose_mode(p);
        mac_vmode_to_var(default_vmode, default_cmode, &p->info.var);
-       valkyrie_init_info(&p->info, p);
+       err = valkyrie_init_info(&p->info, p);
+       if (err < 0)
+               goto out_free;
        valkyrie_init_fix(&p->info.fix, p);
        if (valkyriefb_set_par(&p->info))
                /* "can't happen" */
                printk(KERN_ERR "valkyriefb: can't set default video mode\n");
 
        if ((err = register_framebuffer(&p->info)) != 0)
-               goto out_free;
+               goto out_cmap_free;
 
        printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", p->info.node);
        return 0;
 
+ out_cmap_free:
+       fb_dealloc_cmap(&p->info.cmap);
  out_free:
        if (p->frame_buffer)
                iounmap(p->frame_buffer);
@@ -538,14 +542,15 @@ static void valkyrie_par_to_fix(struct fb_par_valkyrie *par,
                /* ywrapstep, xpanstep, ypanstep */
 }
 
-static void __init valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p)
+static int __init valkyrie_init_info(struct fb_info *info,
+               struct fb_info_valkyrie *p)
 {
        info->fbops = &valkyriefb_ops;
        info->screen_base = p->frame_buffer + 0x1000;
        info->flags = FBINFO_DEFAULT;
        info->pseudo_palette = p->pseudo_palette;
-       fb_alloc_cmap(&info->cmap, 256, 0);
        info->par = &p->par;
+       return fb_alloc_cmap(&info->cmap, 256, 0);
 }