[PATCH] fbdev: fbmon: fix potential divide error in fb_validate_mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can easily use FBIOPUT_VSCREENINFO set fb_var_screeninfo, so
it's possible for a divide by zero error to occur.

Fix this by making sure the divisor is non-zero before the computation.

Signed-off-by: Zhang Shurong <zhang_shurong@xxxxxxxxxxx>
---
 drivers/video/fbdev/core/fbmon.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c
index 79e5bfbdd34c..bdd15b8e3a71 100644
--- a/drivers/video/fbdev/core/fbmon.c
+++ b/drivers/video/fbdev/core/fbmon.c
@@ -1470,6 +1470,9 @@ int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info)
 	if (var->vmode & FB_VMODE_DOUBLE)
 		vtotal *= 2;
 
+	if (!htotal || !vtotal)
+		return -EINVAL;
+
 	hfreq = pixclock/htotal;
 	hfreq = (hfreq + 500) / 1000 * 1000;
 
-- 
2.30.2




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux