* [patch] hangcheck-timer: cleanup casting in hangcheck_init()
@ 2014-10-29 8:42 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2014-10-29 8:42 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors
The 32 bit addition "(hangcheck_margin + hangcheck_tick)" could
potentially overflow. It triggers a static checker warning to have an
overflowed addition followed by a no-op cast. I have moved the cast so
that the addition can't overflow.
Also I removed the unneeded cast on the following line since both
"hangcheck_tsc_margin" and "TIMER_FREQ" are already 64 bit types.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index ebc4c73..a7c5c59 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -168,8 +168,8 @@ static int __init hangcheck_init(void)
printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n",
VERSION_STR, hangcheck_tick, hangcheck_margin);
hangcheck_tsc_margin - (unsigned long long)(hangcheck_margin + hangcheck_tick);
- hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ;
+ (unsigned long long)hangcheck_margin + hangcheck_tick;
+ hangcheck_tsc_margin *= TIMER_FREQ;
hangcheck_tsc = ktime_get_ns();
mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ));
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-10-29 8:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 8:42 [patch] hangcheck-timer: cleanup casting in hangcheck_init() Dan Carpenter
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).