From f8245c26886c912627ebc49f714e4491261224c4 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Tue, 8 May 2007 00:34:07 -0700 Subject: rtc: remove "RTC_ALM_SET mode" bugs This fixes a common glitch in how RTC drivers handle two "set alarm" modes, by getting rid of the surprising/hidden one that was rarely implemented correctly (and which could expose nonportable hardware-specific behavior). The glitch comes from the /dev/rtcX logic implementing the legacy RTC_ALM_SET (limited to 24 hours, needing RTC_AIE_ON) ioctl on top of the RTC driver call providing access to the newer RTC_WKALM_SET (without those limitations) by initializing the day/month/year fields to be invalid ... that second mode. Now, since few RTC drivers check those fields, and most hardware misbehaves when faced with invalid date fields, many RTC drivers will set bogus alarm times on those RTC_ALM_SET code paths. (Several in-tree drivers have that issue, and I also noticed it with code reviews on several new RTC drivers.) This patch ensures that RTC drivers never see such invalid alarm fields, by moving some logic out of rtc-omap into the RTC_ALM_SET code and adding an explicit check (which will prevent the issue on other code paths). Signed-off-by: David Brownell Cc: Scott Wood Cc: Alessandro Zummo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/rtc/interface.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/rtc/interface.c') diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index b5cc5f82436d..ad66c6ecf365 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -125,6 +125,10 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) { int err; + err = rtc_valid_tm(&alarm->time); + if (err != 0) + return err; + err = mutex_lock_interruptible(&rtc->ops_lock); if (err) return -EBUSY; -- cgit v1.2.2