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

lxfb: properly alloc cmap in all cases and don't leak the memory

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..

[dilinger@debian.org: dropped unnecessary code and clean up patch]
[dilinger@debian.org: add error checking and handling]
Signed-off-by: Andres Salomon <dilinger@debian.org>
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

Marco La Porta and committed by
Linus Torvalds
067f1293 57f63bc8

+11 -6
+11 -6
drivers/video/geode/lxfb_core.c
··· 278 278 279 279 static int lxfb_set_par(struct fb_info *info) 280 280 { 281 - if (info->var.bits_per_pixel > 8) { 281 + if (info->var.bits_per_pixel > 8) 282 282 info->fix.visual = FB_VISUAL_TRUECOLOR; 283 - fb_dealloc_cmap(&info->cmap); 284 - } else { 283 + else 285 284 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 286 - fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); 287 - } 288 285 289 286 info->fix.line_length = lx_get_pitch(info->var.xres, 290 287 info->var.bits_per_pixel); ··· 448 451 449 452 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par); 450 453 454 + if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 455 + framebuffer_release(info); 456 + return NULL; 457 + } 458 + 451 459 info->var.grayscale = 0; 452 460 453 461 return info; ··· 581 579 pci_release_region(pdev, 3); 582 580 } 583 581 584 - if (info) 582 + if (info) { 583 + fb_dealloc_cmap(&info->cmap); 585 584 framebuffer_release(info); 585 + } 586 586 587 587 return ret; 588 588 } ··· 608 604 iounmap(par->vp_regs); 609 605 pci_release_region(pdev, 3); 610 606 607 + fb_dealloc_cmap(&info->cmap); 611 608 pci_set_drvdata(pdev, NULL); 612 609 framebuffer_release(info); 613 610 }