Skip to content

Commit

Permalink
lxfb: properly alloc cmap in all cases and don't leak the memory
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marco La Porta authored and Linus Torvalds committed Feb 11, 2009
1 parent 57f63bc commit 067f129
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions drivers/video/geode/lxfb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,10 @@ static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)

static int lxfb_set_par(struct fb_info *info)
{
if (info->var.bits_per_pixel > 8) {
if (info->var.bits_per_pixel > 8)
info->fix.visual = FB_VISUAL_TRUECOLOR;
fb_dealloc_cmap(&info->cmap);
} else {
else
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
}

info->fix.line_length = lx_get_pitch(info->var.xres,
info->var.bits_per_pixel);
Expand Down Expand Up @@ -451,6 +448,11 @@ static struct fb_info * __init lxfb_init_fbinfo(struct device *dev)

info->pseudo_palette = (void *)par + sizeof(struct lxfb_par);

if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
framebuffer_release(info);
return NULL;
}

info->var.grayscale = 0;

return info;
Expand Down Expand Up @@ -579,8 +581,10 @@ static int __init lxfb_probe(struct pci_dev *pdev,
pci_release_region(pdev, 3);
}

if (info)
if (info) {
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}

return ret;
}
Expand All @@ -604,6 +608,7 @@ static void lxfb_remove(struct pci_dev *pdev)
iounmap(par->vp_regs);
pci_release_region(pdev, 3);

fb_dealloc_cmap(&info->cmap);
pci_set_drvdata(pdev, NULL);
framebuffer_release(info);
}
Expand Down

0 comments on commit 067f129

Please sign in to comment.