Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gxfb: properly alloc cmap and plug cmap leak

We weren't properly allocating the cmap for depths greater than 8bpp,
which caused pain for things like DirectFB. Also, we never freed the cmap
memory upon module unload..

Signed-off-by: Andres Salomon <dilinger@debian.org>
Cc: Marco La Porta <marco-laporta@tiscali.it>
Cc: Jordan Crouse <jordan@cosmicpenguin.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andres Salomon and committed by
Linus Torvalds
b14caecd 067f1293

+11 -6
+11 -6
drivers/video/geode/gxfb_core.c
··· 171 171 172 172 static int gxfb_set_par(struct fb_info *info) 173 173 { 174 - if (info->var.bits_per_pixel > 8) { 174 + if (info->var.bits_per_pixel > 8) 175 175 info->fix.visual = FB_VISUAL_TRUECOLOR; 176 - fb_dealloc_cmap(&info->cmap); 177 - } else { 176 + else 178 177 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 179 - fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); 180 - } 181 178 182 179 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); 183 180 ··· 328 331 329 332 info->var.grayscale = 0; 330 333 334 + if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 335 + framebuffer_release(info); 336 + return NULL; 337 + } 338 + 331 339 return info; 332 340 } 333 341 ··· 445 443 pci_release_region(pdev, 1); 446 444 } 447 445 448 - if (info) 446 + if (info) { 447 + fb_dealloc_cmap(&info->cmap); 449 448 framebuffer_release(info); 449 + } 450 450 return ret; 451 451 } 452 452 ··· 471 467 iounmap(par->gp_regs); 472 468 pci_release_region(pdev, 1); 473 469 470 + fb_dealloc_cmap(&info->cmap); 474 471 pci_set_drvdata(pdev, NULL); 475 472 476 473 framebuffer_release(info);