public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: sm750fb: fix division by zero in ps_to_hz()
@ 2026-03-23  7:31 Junrui Luo
  2026-03-23  8:32 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Junrui Luo @ 2026-03-23  7:31 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman
  Cc: linux-fbdev, linux-staging, linux-kernel, Yuhao Jiang, stable,
	Junrui Luo

ps_to_hz() is called from hw_sm750_crtc_set_mode() without validating
that pixclock is non-zero. A zero pixclock passed via FBIOPUT_VSCREENINFO
causes a division by zero.

Fix by rejecting zero pixclock in lynxfb_ops_check_var(), consistent
with other framebuffer drivers.

Fixes: 81dee67e215b ("staging: sm750fb: add sm750 to staging")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
---
 drivers/staging/sm750fb/sm750.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 62f6e0cdff4d..18433aebb4dc 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -490,6 +490,9 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
 		 var->yres,
 		 var->bits_per_pixel);
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	ret = lynxfb_set_color_offsets(info);
 
 	if (ret) {

---
base-commit: c369299895a591d96745d6492d4888259b004a9e
change-id: 20260323-fixes-317d7d967fa2

Best regards,
-- 
Junrui Luo <moonafterrain@outlook.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: sm750fb: fix division by zero in ps_to_hz()
  2026-03-23  7:31 [PATCH] staging: sm750fb: fix division by zero in ps_to_hz() Junrui Luo
@ 2026-03-23  8:32 ` Dan Carpenter
  2026-03-24  6:41   ` Junrui Luo
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2026-03-23  8:32 UTC (permalink / raw)
  To: Junrui Luo
  Cc: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman, linux-fbdev,
	linux-staging, linux-kernel, Yuhao Jiang, stable

On Mon, Mar 23, 2026 at 03:31:56PM +0800, Junrui Luo wrote:
> ps_to_hz() is called from hw_sm750_crtc_set_mode() without validating
> that pixclock is non-zero. A zero pixclock passed via FBIOPUT_VSCREENINFO
> causes a division by zero.
> 
> Fix by rejecting zero pixclock in lynxfb_ops_check_var(), consistent
> with other framebuffer drivers.
> 
> Fixes: 81dee67e215b ("staging: sm750fb: add sm750 to staging")
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
> ---

Seems reasonable.

There is no Closes tag.  Could we get some more information about how
this was found and tested?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: sm750fb: fix division by zero in ps_to_hz()
  2026-03-23  8:32 ` Dan Carpenter
@ 2026-03-24  6:41   ` Junrui Luo
  0 siblings, 0 replies; 3+ messages in thread
From: Junrui Luo @ 2026-03-24  6:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman,
	linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org, Yuhao Jiang, stable@vger.kernel.org

On Mon, Mar 23, 2026 at 11:32:36AM +0300, Dan Carpenter wrote:
> Seems reasonable.
> 
> There is no Closes tag.  Could we get some more information about how
> this was found and tested?

Hi Dan,

Thanks for the review.

This was found through static analysis by Yuhao Jiang.

I don't have SM750 hardware to test on, but verified by code inspection
that the fix is consistent with how other fbdev drivers handle this case.

There is no bug tracker entry for this, so no Closes tag.

Thanks,
Junrui Luo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-24  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23  7:31 [PATCH] staging: sm750fb: fix division by zero in ps_to_hz() Junrui Luo
2026-03-23  8:32 ` Dan Carpenter
2026-03-24  6:41   ` Junrui Luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox