From: Clemens Ladisch <clemens@ladisch.de>
Date: Sun, 30 Oct 2005 23:03:38 +0000 (-0800)
Subject: [PATCH] hpet: fix division by zero in HPET_INFO
X-Git-Tag: firefly_0821_release~39876^2~72^2~18
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=af95eade68da4dfa29c5b64d79cffc9709facf00;p=firefly-linux-kernel-4.4.55.git

[PATCH] hpet: fix division by zero in HPET_INFO

Fix a division by zero that happened when the HPET_INFO ioctl was called
before a timer frequency had been set.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: Bob Picco <bob.picco@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index c85d11de5feb..bc5ee99b9c23 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -494,8 +494,11 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
 		{
 			struct hpet_info info;
 
-			info.hi_ireqfreq = hpet_time_div(hpetp,
-							 devp->hd_ireqfreq);
+			if (devp->hd_ireqfreq)
+				info.hi_ireqfreq =
+					hpet_time_div(hpetp, devp->hd_ireqfreq);
+			else
+				info.hi_ireqfreq = 0;
 			info.hi_flags =
 			    readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK;
 			info.hi_hpet = devp->hd_hpets->hp_which;