]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fbdev: core: fbcvt: avoid division by 0 in fb_cvt_hperiod()
authorSergey Shtylyov <s.shtylyov@omp.ru>
Wed, 14 May 2025 20:35:58 +0000 (23:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:14 +0000 (11:07 +0100)
commit54947530663edcbaaee1314c01fdd8c72861b124
treea79698564066f424e51bef67eced9597a843ef51
parentd62a589eaaec6385e3e2b25cf5a28b4560ace93f
fbdev: core: fbcvt: avoid division by 0 in fb_cvt_hperiod()

[ Upstream commit 3f6dae09fc8c306eb70fdfef70726e1f154e173a ]

In fb_find_mode_cvt(), iff mode->refresh somehow happens to be 0x80000000,
cvt.f_refresh will become 0 when multiplying it by 2 due to overflow. It's
then passed to fb_cvt_hperiod(), where it's used as a divider -- division
by 0 will result in kernel oops. Add a sanity check for cvt.f_refresh to
avoid such overflow...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Fixes: 96fe6a2109db ("[PATCH] fbdev: Add VESA Coordinated Video Timings (CVT) support")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/video/fbdev/core/fbcvt.c