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

gx1fb: 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
35887b1c b14caecd

+11 -6
+11 -6
drivers/video/geode/gx1fb_core.c
··· 136 136 { 137 137 struct geodefb_par *par = info->par; 138 138 139 - if (info->var.bits_per_pixel == 16) { 139 + if (info->var.bits_per_pixel == 16) 140 140 info->fix.visual = FB_VISUAL_TRUECOLOR; 141 - fb_dealloc_cmap(&info->cmap); 142 - } else { 141 + else 143 142 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 144 - fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); 145 - } 146 143 147 144 info->fix.line_length = gx1_line_delta(info->var.xres, info->var.bits_per_pixel); 148 145 ··· 312 315 if (!par->panel_x) 313 316 par->enable_crt = 1; /* fall back to CRT if no panel is specified */ 314 317 318 + if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 319 + framebuffer_release(info); 320 + return NULL; 321 + } 315 322 return info; 316 323 } 317 324 ··· 375 374 release_mem_region(gx1_gx_base() + 0x8300, 0x100); 376 375 } 377 376 378 - if (info) 377 + if (info) { 378 + fb_dealloc_cmap(&info->cmap); 379 379 framebuffer_release(info); 380 + } 381 + 380 382 return ret; 381 383 } 382 384 ··· 399 395 iounmap(par->dc_regs); 400 396 release_mem_region(gx1_gx_base() + 0x8300, 0x100); 401 397 398 + fb_dealloc_cmap(&info->cmap); 402 399 pci_set_drvdata(pdev, NULL); 403 400 404 401 framebuffer_release(info);