* [PATCH] fbdev: sstfb: Fix potential divide by zero
@ 2025-06-14 0:44 Alex Guo
0 siblings, 0 replies; 2+ messages in thread
From: Alex Guo @ 2025-06-14 0:44 UTC (permalink / raw)
To: deller
Cc: tzimmermann, alexguo1023, gonzalo.silvalde, linux-fbdev,
dri-devel, linux-kernel
Variable var->pixclock can be set by user. In case it equals to
zero, divide by zero would occur in sstfb_check_var. Similar
crashes have happened in other fbdev drivers. We fix this by
checking whether 'pixclock' is zero.
Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
drivers/video/fbdev/sstfb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c
index 2ea947f57efb..fd387ca8401b 100644
--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -359,7 +359,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
int tiles_in_X, real_length;
unsigned int freq;
- if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
+ if (var->pixclock && sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
PICOS2KHZ(var->pixclock));
return -EINVAL;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] fbdev: sstfb: Fix potential divide by zero
@ 2025-06-14 0:50 Alex Guo
0 siblings, 0 replies; 2+ messages in thread
From: Alex Guo @ 2025-06-14 0:50 UTC (permalink / raw)
To: deller; +Cc: alexguo1023, linux-fbdev, dri-devel, linux-kernel
Variable var->pixclock can be set by user. In case it equals to
zero, divide by zero would occur in sstfb_check_var. Similar
crashes have happened in other fbdev drivers. We fix this by
checking whether 'pixclock' is zero.
Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
drivers/video/fbdev/sstfb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c
index 2ea947f57efb..fd387ca8401b 100644
--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -359,7 +359,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
int tiles_in_X, real_length;
unsigned int freq;
- if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
+ if (var->pixclock && sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
PICOS2KHZ(var->pixclock));
return -EINVAL;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-14 0:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-14 0:50 [PATCH] fbdev: sstfb: Fix potential divide by zero Alex Guo
-- strict thread matches above, loose matches on Subject: below --
2025-06-14 0:44 Alex Guo
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).