s3c-fb: fix resource releasing on error during probing
authorKrzysztof Helt <krzysztof.h1@wp.pl>
Tue, 16 Jun 2009 22:34:33 +0000 (15:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jun 2009 02:47:59 +0000 (19:47 -0700)
All resources are released in s3c_fb_win_release so remove other places of
resources releasing.  Add releasing of an allocated fb_info structure as
well.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/s3c-fb.c

index 53bca28..43680e5 100644 (file)
@@ -725,9 +725,12 @@ static void s3c_fb_free_memory(struct s3c_fb *sfb, struct s3c_fb_win *win)
  */
 static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win)
 {
-       fb_dealloc_cmap(&win->fbinfo->cmap);
-       unregister_framebuffer(win->fbinfo);
-       s3c_fb_free_memory(sfb, win);
+       if (win->fbinfo) {
+               unregister_framebuffer(win->fbinfo);
+               fb_dealloc_cmap(&win->fbinfo->cmap);
+               s3c_fb_free_memory(sfb, win);
+               framebuffer_release(win->fbinfo);
+       }
 }
 
 /**
@@ -778,7 +781,7 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
        ret = s3c_fb_alloc_memory(sfb, win);
        if (ret) {
                dev_err(sfb->dev, "failed to allocate display memory\n");
-               goto err_framebuffer;
+               return ret;
        }
 
        /* setup the r/b/g positions for the window's palette */
@@ -801,7 +804,7 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
        ret = s3c_fb_check_var(&fbinfo->var, fbinfo);
        if (ret < 0) {
                dev_err(sfb->dev, "check_var failed on initial video params\n");
-               goto err_alloc_mem;
+               return ret;
        }
 
        /* create initial colour map */
@@ -821,20 +824,13 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
        ret = register_framebuffer(fbinfo);
        if (ret < 0) {
                dev_err(sfb->dev, "failed to register framebuffer\n");
-               goto err_alloc_mem;
+               return ret;
        }
 
        *res = win;
        dev_info(sfb->dev, "window %d: fb %s\n", win_no, fbinfo->fix.id);
 
        return 0;
-
-err_alloc_mem:
-       s3c_fb_free_memory(sfb, win);
-
-err_framebuffer:
-       unregister_framebuffer(fbinfo);
-       return ret;
 }
 
 /**