Skip to content

Commit c75f5a5

Browse files
bluesheep1337hdeller
authored andcommitted
fbdev: imsttfb: Fix use after free bug in imsttfb_probe
A use-after-free bug may occur if init_imstt invokes framebuffer_release and free the info ptr. The caller, imsttfb_probe didn't notice that and still keep the ptr as private data in pdev. If we remove the driver which will call imsttfb_remove to make cleanup, UAF happens. Fix it by return error code if bad case happens in init_imstt. Signed-off-by: Zheng Wang <zyytlz.wz@163.com> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 6208890 commit c75f5a5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/video/fbdev/imsttfb.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ static const struct fb_ops imsttfb_ops = {
13471347
.fb_ioctl = imsttfb_ioctl,
13481348
};
13491349

1350-
static void init_imstt(struct fb_info *info)
1350+
static int init_imstt(struct fb_info *info)
13511351
{
13521352
struct imstt_par *par = info->par;
13531353
__u32 i, tmp, *ip, *end;
@@ -1420,7 +1420,7 @@ static void init_imstt(struct fb_info *info)
14201420
|| !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) {
14211421
printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel);
14221422
framebuffer_release(info);
1423-
return;
1423+
return -ENODEV;
14241424
}
14251425

14261426
sprintf(info->fix.id, "IMS TT (%s)", par->ramdac == IBM ? "IBM" : "TVP");
@@ -1456,12 +1456,13 @@ static void init_imstt(struct fb_info *info)
14561456

14571457
if (register_framebuffer(info) < 0) {
14581458
framebuffer_release(info);
1459-
return;
1459+
return -ENODEV;
14601460
}
14611461

14621462
tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8;
14631463
fb_info(info, "%s frame buffer; %uMB vram; chip version %u\n",
14641464
info->fix.id, info->fix.smem_len >> 20, tmp);
1465+
return 0;
14651466
}
14661467

14671468
static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -1529,10 +1530,10 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
15291530
if (!par->cmap_regs)
15301531
goto error;
15311532
info->pseudo_palette = par->palette;
1532-
init_imstt(info);
1533-
1534-
pci_set_drvdata(pdev, info);
1535-
return 0;
1533+
ret = init_imstt(info);
1534+
if (!ret)
1535+
pci_set_drvdata(pdev, info);
1536+
return ret;
15361537

15371538
error:
15381539
if (par->dc_regs)

0 commit comments

Comments
 (0)