mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 20:33:58 -04:00
fbdev: imxfb: Check fb_add_videomode to prevent null-ptr-deref
[ Upstream commit da11e6a30e0bb8e911288bdc443b3dc8f6a7cac7 ]
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 17186f1f90d3 ("fbdev:
Fix do_register_framebuffer to prevent null-ptr-deref in fb_videomode_to_var").
Fixes: 1b6c79361b ("video: imxfb: Add DT support")
Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e4c864a14a
commit
69373502c2
1 changed files with 7 additions and 2 deletions
|
|
@ -992,8 +992,13 @@ static int imxfb_probe(struct platform_device *pdev)
|
|||
|
||||
|
||||
INIT_LIST_HEAD(&info->modelist);
|
||||
for (i = 0; i < fbi->num_modes; i++)
|
||||
fb_add_videomode(&fbi->mode[i].mode, &info->modelist);
|
||||
for (i = 0; i < fbi->num_modes; i++) {
|
||||
ret = fb_add_videomode(&fbi->mode[i].mode, &info->modelist);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to add videomode\n");
|
||||
goto failed_cmap;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This makes sure that our colour bitfield
|
||||
|
|
|
|||
Loading…
Reference in a new issue