Commit aba6ab57 authored by Dan Carpenter's avatar Dan Carpenter Committed by Helge Deller

fbdev: imsttfb: fix a resource leak in probe

I've re-written the error handling but the bug is that if init_imstt()
fails we need to call iounmap(par->cmap_regs).

Fixes: c75f5a55 ("fbdev: imsttfb: Fix use after free bug in imsttfb_probe")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent e08c30ef
...@@ -1496,8 +1496,8 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1496,8 +1496,8 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!request_mem_region(addr, size, "imsttfb")) { if (!request_mem_region(addr, size, "imsttfb")) {
printk(KERN_ERR "imsttfb: Can't reserve memory region\n"); printk(KERN_ERR "imsttfb: Can't reserve memory region\n");
framebuffer_release(info); ret = -ENODEV;
return -ENODEV; goto release_info;
} }
switch (pdev->device) { switch (pdev->device) {
...@@ -1514,36 +1514,39 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1514,36 +1514,39 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
printk(KERN_INFO "imsttfb: Device 0x%x unknown, " printk(KERN_INFO "imsttfb: Device 0x%x unknown, "
"contact maintainer.\n", pdev->device); "contact maintainer.\n", pdev->device);
ret = -ENODEV; ret = -ENODEV;
goto error; goto release_mem_region;
} }
info->fix.smem_start = addr; info->fix.smem_start = addr;
info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ?
0x400000 : 0x800000); 0x400000 : 0x800000);
if (!info->screen_base) if (!info->screen_base)
goto error; goto release_mem_region;
info->fix.mmio_start = addr + 0x800000; info->fix.mmio_start = addr + 0x800000;
par->dc_regs = ioremap(addr + 0x800000, 0x1000); par->dc_regs = ioremap(addr + 0x800000, 0x1000);
if (!par->dc_regs) if (!par->dc_regs)
goto error; goto unmap_screen_base;
par->cmap_regs_phys = addr + 0x840000; par->cmap_regs_phys = addr + 0x840000;
par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000); par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000);
if (!par->cmap_regs) if (!par->cmap_regs)
goto error; goto unmap_dc_regs;
info->pseudo_palette = par->palette; info->pseudo_palette = par->palette;
ret = init_imstt(info); ret = init_imstt(info);
if (ret) if (ret)
goto error; goto unmap_cmap_regs;
pci_set_drvdata(pdev, info); pci_set_drvdata(pdev, info);
return ret; return 0;
error: unmap_cmap_regs:
if (par->dc_regs) iounmap(par->cmap_regs);
iounmap(par->dc_regs); unmap_dc_regs:
if (info->screen_base) iounmap(par->dc_regs);
iounmap(info->screen_base); unmap_screen_base:
iounmap(info->screen_base);
release_mem_region:
release_mem_region(addr, size); release_mem_region(addr, size);
release_info:
framebuffer_release(info); framebuffer_release(info);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment