Bläddra i källkod

amba-clcd: fix cmap memory leaks

- fix cmap leak in removal path

- fix cmap leak when register_framebuffer fails

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>
Andres Salomon 16 år sedan
förälder
incheckning
909baf0092
1 ändrade filer med 7 tillägg och 1 borttagningar
  1. 7 1
      drivers/video/amba-clcd.c

+ 7 - 1
drivers/video/amba-clcd.c

@@ -408,7 +408,9 @@ static int clcdfb_register(struct clcd_fb *fb)
 	/*
 	/*
 	 * Allocate colourmap.
 	 * Allocate colourmap.
 	 */
 	 */
-	fb_alloc_cmap(&fb->fb.cmap, 256, 0);
+	ret = fb_alloc_cmap(&fb->fb.cmap, 256, 0);
+	if (ret)
+		goto unmap;
 
 
 	/*
 	/*
 	 * Ensure interrupts are disabled.
 	 * Ensure interrupts are disabled.
@@ -426,6 +428,8 @@ static int clcdfb_register(struct clcd_fb *fb)
 
 
 	printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret);
 	printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret);
 
 
+	fb_dealloc_cmap(&fb->fb.cmap);
+ unmap:
 	iounmap(fb->regs);
 	iounmap(fb->regs);
  free_clk:
  free_clk:
 	clk_put(fb->clk);
 	clk_put(fb->clk);
@@ -485,6 +489,8 @@ static int clcdfb_remove(struct amba_device *dev)
 
 
 	clcdfb_disable(fb);
 	clcdfb_disable(fb);
 	unregister_framebuffer(&fb->fb);
 	unregister_framebuffer(&fb->fb);
+	if (fb->fb.cmap.len)
+		fb_dealloc_cmap(&fb->fb.cmap);
 	iounmap(fb->regs);
 	iounmap(fb->regs);
 	clk_put(fb->clk);
 	clk_put(fb->clk);