linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Guo <alexguo1023@gmail.com>
To: deller@gmx.de
Cc: FlorianSchandinat@gmx.de, alexguo1023@gmail.com,
	linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] fbdev: via: hw: Fix potential divide by zero
Date: Fri, 13 Jun 2025 21:03:18 -0400	[thread overview]
Message-ID: <20250614010318.3128558-1-alexguo1023@gmail.com> (raw)

Variable var->pixclock can be set by user. In case it equals to
zero, divide by zero would occur in viafb_fill_crtc_timing.
Similar crashes have happened in other fbdev drivers. We fix this
by checking whether 'pixclock' is zero.

Similar commit: commit 16844e58704 ("video: fbdev: tridentfb:
Error out if 'pixclock' equals zero")

Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
 drivers/video/fbdev/via/hw.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/via/hw.c b/drivers/video/fbdev/via/hw.c
index 66afd7be00cc..31e0cac91889 100644
--- a/drivers/video/fbdev/via/hw.c
+++ b/drivers/video/fbdev/via/hw.c
@@ -1488,8 +1488,9 @@ void viafb_fill_crtc_timing(const struct fb_var_screeninfo *var,
 	if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266
 		&& viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)
 		viafb_load_FIFO_reg(iga, var->xres, var->yres);
-
-	viafb_set_vclock(PICOS2KHZ(var->pixclock) * 1000, iga);
+	
+	if (var->pixclock)
+		viafb_set_vclock(PICOS2KHZ(var->pixclock) * 1000, iga);
 }
 
 void viafb_init_chip_info(int chip_type)
-- 
2.34.1


                 reply	other threads:[~2025-06-14  1:03 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=20250614010318.3128558-1-alexguo1023@gmail.com \
    --to=alexguo1023@gmail.com \
    --cc=FlorianSchandinat@gmx.de \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).