Skip to content

Commit da11e6a

Browse files
WhiteFox-Projecthdeller
authored andcommitted
fbdev: imxfb: Check fb_add_videomode to prevent null-ptr-deref
fb_add_videomode() can fail with -ENOMEM when its internal kmalloc() cannot allocate a struct fb_modelist. If that happens, the modelist stays empty but the driver continues to register. Add a check for its return value to prevent poteintial null-ptr-deref, which is similar to the commit 17186f1 ("fbdev: Fix do_register_framebuffer to prevent null-ptr-deref in fb_videomode_to_var"). Fixes: 1b6c793 ("video: imxfb: Add DT support") Signed-off-by: Chenyuan Yang <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 57ba4d5 commit da11e6a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/video/fbdev/imxfb.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,8 +996,13 @@ static int imxfb_probe(struct platform_device *pdev)
996996
info->fix.smem_start = fbi->map_dma;
997997

998998
INIT_LIST_HEAD(&info->modelist);
999-
for (i = 0; i < fbi->num_modes; i++)
1000-
fb_add_videomode(&fbi->mode[i].mode, &info->modelist);
999+
for (i = 0; i < fbi->num_modes; i++) {
1000+
ret = fb_add_videomode(&fbi->mode[i].mode, &info->modelist);
1001+
if (ret) {
1002+
dev_err(&pdev->dev, "Failed to add videomode\n");
1003+
goto failed_cmap;
1004+
}
1005+
}
10011006

10021007
/*
10031008
* This makes sure that our colour bitfield

0 commit comments

Comments
 (0)