amba-clcd: fix cmap memory leaks
PATCH 13/15 amba-clcd: fix cmap memory leaks
- fix cmap leak in removal path
- fix cmap leak when register_framebuffer fails
--- drivers/video/amba-clcd.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/video/amba-clcd.c +7 -1
@@ -408,7 +408,9 @@ static int clcdfb_register(struct clcd_fb *fb)/* * 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.
@@ -426,6 +428,8 @@ static int clcdfb_register(struct clcd_fb *fb)printk (KERN_ERR "CLCD: cannot register framebuffer (%d)\n" , ret); +fb_dealloc_cmap (&fb->fb.cmap); + unmap:iounmap (fb->regs); free_clk:clk_put (fb->clk);
@@ -485,6 +489,8 @@ static int clcdfb_remove(struct amba_device *dev)clcdfb_disable (fb);unregister_framebuffer (&fb->fb); +if (fb->fb.cmap.len) +fb_dealloc_cmap (&fb->fb.cmap);iounmap (fb->regs);clk_put (fb->clk);
Signature · 9 lines
1.5.6.5 ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
Quoted 6 lines · On Sat, 7 Feb 2009 12:18:48 -0500 Andres Salomon <[email protected]> wrote:
- fix cmap leak in removal path
- fix cmap leak whenregister_framebufferfailsSigned-off-by Andres Salomon <[email protected]>---
One comment (see below).
Quoted 28 lines
drivers/video/amba-clcd.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)drivers/video/amba-clcd.c +5
-1@@ -408,7 +408,9 @@ static int clcdfb_register(struct clcd_fb *fb)/* * 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. @@ -426,6 +428,8 @@ static int clcdfb_register(struct clcd_fb *fb)printk (KERN_ERR "CLCD: cannot register framebuffer (%d)\n" , ret); +fb_dealloc_cmap (&fb->fb.cmap); + unmap:iounmap (fb->regs); free_clk:clk_put (fb->clk);
drivers/video/amba-clcd.c static int clcdfb_remove(struct amba_device *dev) · line 493
Quoted 5 lines
drivers/video/amba-clcd.c +2
-0@@ -485,6 +489,8 @@ static int clcdfb_remove(struct amba_device *dev)clcdfb_disable (fb);unregister_framebuffer (&fb->fb); +if (fb->fb.cmap.len) +fb_dealloc_cmap (&fb->fb.cmap);
Is this if() needed? Is this function called twice (or more) or can it be called without the cmap allocated?
Quoted 6 lines
drivers/video/amba-clcd.c +0
-0iounmap (fb->regs);clk_put (fb->clk);Signature · 1 line
1.5.6.5
Quoted 14 lines · On Mon, 9 Feb 2009 21:16:14 +0100 Krzysztof Helt <[email protected]> wrote:
Quoted 6 lines · On Sat, 7 Feb 2009 12:18:48 -0500 Andres Salomon <[email protected]> wrote:
- fix cmap leak in removal path
- fix cmap leak whenregister_framebufferfailsSigned-off-by Andres Salomon <[email protected]>---
Acked-by Krzysztof Helt <[email protected]>One comment (see below).
[...]
Quoted 9 lines
drivers/video/amba-clcd.c static int clcdfb_remove(struct amba_device · line 493
Quoted 6 lines
drivers/video/amba-clcd.c +2
-0@@ -485,6 +489,8 @@ static int clcdfb_remove(struct amba_device *dev)clcdfb_disable (fb);unregister_framebuffer (&fb->fb); +if (fb->fb.cmap.len) +fb_dealloc_cmap (&fb->fb.cmap);Is this
if()needed? Is this function called twice (or more) or can it be called without the cmap allocated?
It was added as a precaution due to the fb->board->remove callbacks, but I think I misunderstood the code. So my official answer is "I'm not sure." :)
Quoted 7 lines
Quoted 7 lines
drivers/video/amba-clcd.c +0
-0iounmap (fb->regs);clk_put (fb->clk);Signature · 1 line
1.5.6.5