RTC: Prevents a division by zero in kernel code.

This patch prevents a user space program from calling the RTC_IRQP_SET
ioctl with a negative value of frequency. Also, if this call is make
with a zero value of frequency, there would be a division by zero in the
kernel code.

[jstultz: Also initialize irq_freq to 1 to catch other divbyzero issues]

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>
Signed-off-by: John Stultz <john.stultz@linaro.org>

authored by Marcelo Roberto Jimenez and committed by John Stultz 83a06bf5 9118626a

+4
+1
drivers/rtc/class.c
··· 143 143 rtc->id = id; 144 144 rtc->ops = ops; 145 145 rtc->owner = owner; 146 + rtc->irq_freq = 1; 146 147 rtc->max_user_freq = 64; 147 148 rtc->dev.parent = dev; 148 149 rtc->dev.class = rtc_class;
+3
drivers/rtc/interface.c
··· 464 464 int err = 0; 465 465 unsigned long flags; 466 466 467 + if (freq <= 0) 468 + return -EINVAL; 469 + 467 470 spin_lock_irqsave(&rtc->irq_task_lock, flags); 468 471 if (rtc->irq_task != NULL && task == NULL) 469 472 err = -EBUSY;