lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1474909283-15826-1-git-send-email-pure.logic@nexus-software.ie>
Date:   Mon, 26 Sep 2016 18:01:23 +0100
From:   Bryan O'Donoghue <pure.logic@...us-software.ie>
To:     gregkh@...uxfoundation.org
Cc:     johan@...oldconsulting.com, elder@...aro.org,
        linux-kernel@...r.kernel.org,
        Bryan O'Donoghue <pure.logic@...us-software.ie>
Subject: [PATCH] staging: greybus/timesync: avoid divide by zero on X86 Qemu

A system configured without CONFIG_CPUFREQ will return 0 for cpufreq_get().
greybus-timesync can subsequently then do a divide-by-zero as result. This
patch fixes by checking for a zero return value from cpufreq_get() and
setting to a default value of 19.2MHz.

Reported-by: Rui Miguel Silva <rmfrfs@...il.com>
Signed-off-by: Bryan O'Donoghue <pure.logic@...us-software.ie>
---
 drivers/staging/greybus/timesync_platform.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/timesync_platform.c b/drivers/staging/greybus/timesync_platform.c
index 50e8883..113f3d6 100644
--- a/drivers/staging/greybus/timesync_platform.c
+++ b/drivers/staging/greybus/timesync_platform.c
@@ -20,6 +20,8 @@
 #include "greybus.h"
 #include "arche_platform.h"
 
+#define DEFAULT_FRAMETIME_CLOCK_HZ 19200000
+
 static u32 gb_timesync_clock_frequency;
 int (*arche_platform_change_state_cb)(enum arche_platform_state state,
 				      struct gb_timesync_svc *pdata);
@@ -32,8 +34,11 @@ u64 gb_timesync_platform_get_counter(void)
 
 u32 gb_timesync_platform_get_clock_rate(void)
 {
-	if (unlikely(!gb_timesync_clock_frequency))
-		return cpufreq_get(0);
+	if (unlikely(!gb_timesync_clock_frequency)) {
+		gb_timesync_clock_frequency = cpufreq_get(0);
+		if (!gb_timesync_clock_frequency)
+			gb_timesync_clock_frequency = DEFAULT_FRAMETIME_CLOCK_HZ;
+	}
 
 	return gb_timesync_clock_frequency;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ