Commit 7a3e7a62 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[PATCH] janitor: video/fbcmap: kmalloc() audit

From: "Randy.Dunlap" <rddunlap@osdl.org>

From: Leann Ogasawara <ogasawara@osdl.org>

Handle kmalloc() failures
parent d53303ed
......@@ -98,14 +98,14 @@ int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp)
if (!len)
return 0;
if (!(cmap->red = kmalloc(size, GFP_ATOMIC)))
return -1;
goto fail;
if (!(cmap->green = kmalloc(size, GFP_ATOMIC)))
return -1;
goto fail;
if (!(cmap->blue = kmalloc(size, GFP_ATOMIC)))
return -1;
goto fail;
if (transp) {
if (!(cmap->transp = kmalloc(size, GFP_ATOMIC)))
return -1;
goto fail;
} else
cmap->transp = NULL;
}
......@@ -113,6 +113,10 @@ int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp)
cmap->len = len;
fb_copy_cmap(fb_default_cmap(len), cmap, 0);
return 0;
fail:
fb_dealloc_cmap(cmap);
return -1;
}
/**
......@@ -126,13 +130,9 @@ int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp)
void fb_dealloc_cmap(struct fb_cmap *cmap)
{
if (cmap->red)
kfree(cmap->red);
if (cmap->green)
kfree(cmap->green);
if (cmap->blue)
kfree(cmap->blue);
if (cmap->transp)
kfree(cmap->transp);
cmap->red = cmap->green = cmap->blue = cmap->transp = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment