提交 b14caecd 编写于 作者: A Andres Salomon 提交者: Linus Torvalds

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: NAndres Salomon <dilinger@debian.org>
Cc: Marco La Porta <marco-laporta@tiscali.it>
Cc: Jordan Crouse <jordan@cosmicpenguin.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 067f1293
...@@ -171,13 +171,10 @@ static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -171,13 +171,10 @@ static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
static int gxfb_set_par(struct fb_info *info) static int gxfb_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; info->fix.visual = FB_VISUAL_TRUECOLOR;
fb_dealloc_cmap(&info->cmap); else
} else {
info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
}
info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel);
...@@ -331,6 +328,11 @@ static struct fb_info * __init gxfb_init_fbinfo(struct device *dev) ...@@ -331,6 +328,11 @@ static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
info->var.grayscale = 0; info->var.grayscale = 0;
if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
framebuffer_release(info);
return NULL;
}
return info; return info;
} }
...@@ -443,8 +445,10 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i ...@@ -443,8 +445,10 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
pci_release_region(pdev, 1); pci_release_region(pdev, 1);
} }
if (info) if (info) {
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info); framebuffer_release(info);
}
return ret; return ret;
} }
...@@ -467,6 +471,7 @@ static void gxfb_remove(struct pci_dev *pdev) ...@@ -467,6 +471,7 @@ static void gxfb_remove(struct pci_dev *pdev)
iounmap(par->gp_regs); iounmap(par->gp_regs);
pci_release_region(pdev, 1); pci_release_region(pdev, 1);
fb_dealloc_cmap(&info->cmap);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
framebuffer_release(info); framebuffer_release(info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册