projects/linux·commit fa7af8b1

rtc: test before subtraction on unsigned

fa7af8b1 · Roel Kluin <[email protected]> · 2009-03-31 15:25:00 -07:00

new_alarm is unsigned so test before the subtraction.

[[email protected]: time-wrapping fix]
Signed-off-by: Roel Kluin <[email protected]>
Cc: David Brownell <[email protected]>
Cc: Alessandro Zummo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
fa7af8b1bb6dfca7a0c8541683a9bfffbc8dd345
Parents
c08cf9da

Changes

1 files changed · +3 −3

FileStatusAddDelContent
drivers/rtc/rtc-ds1374.cmodified+3−3View file

drivers/rtc/rtc-ds1374.c

View file
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index a5b0fc0..4d32e32 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -222,16 +222,16 @@ static int ds1374_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
rtc_tm_to_time(&alarm->time, &new_alarm);
rtc_tm_to_time(&now, &itime);
- new_alarm -= itime;
-
/* This can happen due to races, in addition to dates that are
* truly in the past. To avoid requiring the caller to check for
* races, dates in the past are assumed to be in the recent past
* (i.e. not something that we'd rather the caller know about via
* an error), and the alarm is set to go off as soon as possible.
*/
- if (new_alarm <= 0)
+ if (time_before_eq(new_alarm, itime))
new_alarm = 1;
+ else
+ new_alarm -= itime;
mutex_lock(&ds1374->mutex);