diff options
| author | Wang Haoran <haoranwangsec@gmail.com> | 2026-10-23 15:56:11 +0800 |
|---|---|---|
| committer | Helge Deller <deller@gmx.de> | 2026-10-25 08:57:27 +0100 |
| commit | 01d1204582f16e8b7bfce29648e5cf77a585d962 (patch) | |
| tree | 6207f28912dfda76907c05259cbf5da186096911 /tools/lib/python | |
| parent | e220f288b76b734e749c0035cc79a98b920a24d5 (diff) | |
fbdev: atmel_lcdfb: fix list_first_entry() on possibly empty modelist in probe
list_first_entry() does not return NULL on an empty list; it returns a
bogus pointer computed by container_of() from the list head.
atmel_lcdfb_probe() initializes info->modelist with INIT_LIST_HEAD()
and later takes its first entry with list_first_entry(), assuming
atmel_lcdfb_of_init() populated it. However, atmel_lcdfb_of_init()
drops the return value of fb_add_videomode() — unlike every other
fallible call in the same function — so if fb_add_videomode() fails
(its internal kmalloc can return -ENOMEM under memory pressure or
fault injection), the list stays empty while of_init() reports
success. The probe path then dereferences the bogus pointer in
fb_videomode_to_var(&info->var, &modelist->mode). Because the bogus
pointer lands inside the contiguous fb_info allocation, this may not
fault immediately; instead it silently reads adjacent memory as a
struct fb_videomode and programs garbage timing parameters into the
LCD controller. This was found by code audit; we do not have Atmel
hardware to reproduce it.
Fix this on two levels: check the return value of fb_add_videomode()
in atmel_lcdfb_of_init() so the failure is propagated (root cause),
and use list_first_entry_or_null() in atmel_lcdfb_probe() with a NULL
check that fails probe gracefully with -EINVAL (defense in depth),
consistent with the surrounding error handling which bails out to
stop_clk.
Reported-by: Wang Haoran <haoranwangsec@gmail.com>
Reported-by: Li Ximo <lixicaicai@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Wang Haoran <haoranwangsec@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
