summaryrefslogtreecommitdiff
path: root/drivers/video
diff options
context:
space:
mode:
authorChenyuan Yang <chenyuan0y@gmail.com>2025-07-23 22:25:34 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-15 12:08:56 +0200
commit4b5d36cc3014986e6fac12eaa8433fe56801d4ce (patch)
treed7a6c9eba90b6402e427cdc651d1e60d0f86ea91 /drivers/video
parent0aa273dbcf5305d15c133797a5d43e65e6fe0983 (diff)
downloadlinux-4b5d36cc3014986e6fac12eaa8433fe56801d4ce.tar.gz
linux-4b5d36cc3014986e6fac12eaa8433fe56801d4ce.tar.bz2
linux-4b5d36cc3014986e6fac12eaa8433fe56801d4ce.zip
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: 1b6c79361ba5 ("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>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbdev/imxfb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c
index 7042a43b81d8..5f9e98423d65 100644
--- a/drivers/video/fbdev/imxfb.c
+++ b/drivers/video/fbdev/imxfb.c
@@ -1004,8 +1004,13 @@ static int imxfb_probe(struct platform_device *pdev)
info->fix.smem_start = fbi->map_dma;
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