From patchwork Wed Feb 2 18:04:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: RTC: Prevents a division by zero in kernel code. Date: Wed, 02 Feb 2011 08:04:02 -0000 From: Marcelo Roberto Jimenez X-Patchwork-Id: 81499 Message-Id: <1296669842-32611-1-git-send-email-mroberto@cpti.cetuc.puc-rio.br> To: mroberto@cpti.cetuc.puc-rio.br, a.zummo@towertech.it, john.stultz@linaro.org Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org 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. Signed-off-by: Marcelo Roberto Jimenez --- drivers/rtc/interface.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 925006d..a0c0196 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -464,6 +464,9 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq) int err = 0; unsigned long flags; + if (freq <= 0) + return -EINVAL; + spin_lock_irqsave(&rtc->irq_task_lock, flags); if (rtc->irq_task != NULL && task == NULL) err = -EBUSY;