]> 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:05:15 +0000 (11:05 +0100)
commit2d63433e8eaa3c91b2948190e395bc67009db0d9
tree1d899bb6d1daa22bdb93d0ecd212b5efd58f8a5d
parent1fd889c145722579aa038c31cbc07cfdd4d75166
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