From: Danila Chernetsov <listdansp@mail.ru>
To: Helge Deller <deller@gmx.de>
Cc: Danila Chernetsov <listdansp@mail.ru>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
lvc-project@linuxtesting.org
Subject: [PATCH] fbdev: kyro: Fix division by zero in SetOverlayViewPort()
Date: Fri, 27 Nov 2026 23:32:35 +0000 [thread overview]
Message-ID: <20261127233235.114388-1-listdansp@mail.ru> (raw)
In SetOverlayViewPort(), the vertical scale factor is calculated as
(ulDest << 11) / ulSrc and used as a divisor a few lines later. The
quotient truncates to zero if the on-screen viewport is a single line
high (ulDest == 0), or if the overlay surface was created with zero
height, in which case ulSrc wraps around to U32_MAX. The existing
check "if (ulSrc <= 1)" does not prevent either case, and the
division by ulFxScale causes a divide error in the kernel.
Return -EINVAL when the scale factor is zero.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Danila Chernetsov <listdansp@mail.ru>
---
drivers/video/fbdev/kyro/STG4000OverlayDevice.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/video/fbdev/kyro/STG4000OverlayDevice.c b/drivers/video/fbdev/kyro/STG4000OverlayDevice.c
index cb6fa0991fca..fae1f5d5ec8a 100644
--- a/drivers/video/fbdev/kyro/STG4000OverlayDevice.c
+++ b/drivers/video/fbdev/kyro/STG4000OverlayDevice.c
@@ -376,6 +376,9 @@ int SetOverlayViewPort(volatile STG4000REG __iomem *pSTGReg,
ulFxScale = (ulDest << 11) / ulSrc; /* fixed point scale factor */
ulFxOffset = (srcDest.lDstY2 - srcDest.ulDstY2) << 11;
+ if (!ulFxScale)
+ return -EINVAL;
+
ulSrcBottom = ulSrcBottom - (ulFxOffset / ulFxScale);
ulSrc = ulSrcBottom - ulSrcTop;
ulHeight = ulSrc;
--
2.25.1
reply other threads:[~2026-11-27 23:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127233235.114388-1-listdansp@mail.ru \
--to=listdansp@mail.ru \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox