From: John Stultz <john.stultz@linaro.org>
To: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>,
Thomas Gleixner <tglx@linutronix.de>
Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RTC: Prevents a division by zero in kernel code.
Date: Wed, 02 Feb 2011 12:34:33 -0800 [thread overview]
Message-ID: <1296678873.3336.248.camel@work-vm> (raw)
In-Reply-To: <1296669842-32611-1-git-send-email-mroberto@cpti.cetuc.puc-rio.br>
On Wed, 2011-02-02 at 16:04 -0200, Marcelo Roberto Jimenez wrote:
> 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 <mroberto@cpti.cetuc.puc-rio.br>
Probably need to also initialize irq_freq to 1 on rtc_device_register so
we don't trip over the divbyzero on rtc devices that don't initialize
that value.
I'll add that and fwd on your patch!
Great catch!
thanks
-john
> ---
> 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;
prev parent reply other threads:[~2011-02-02 20:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-02 18:04 [PATCH] RTC: Prevents a division by zero in kernel code Marcelo Roberto Jimenez
2011-02-02 20:34 ` John Stultz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1296678873.3336.248.camel@work-vm \
--to=john.stultz@linaro.org \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=mroberto@cpti.cetuc.puc-rio.br \
--cc=rtc-linux@googlegroups.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox