From patchwork Wed Feb 2 18:04:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Roberto Jimenez X-Patchwork-Id: 81499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-gx0-f184.google.com (mail-gx0-f184.google.com [209.85.161.184]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 0E903B70FF for ; Thu, 3 Feb 2011 05:04:21 +1100 (EST) Received: by gxk6 with SMTP id 6sf149574gxk.11 for ; Wed, 02 Feb 2011 10:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:mime-version:x-beenthere:received-spf:from:to :cc:subject:date:message-id:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=x8x6krQLPy0EXlgsepD/uYDtKjQEKecShZhCEd0fWcY=; b=Mb9B5rcxT1mTY+N0YfDWosC7wWkUhpv0bo1jFLmztM+3CO5x4m4glYhCtysuH8nb9F 363G82c+xCLkyhdlSOrUqRiZZU1uop5p1frTNmU+95HxjeRTThvKkT2cmEiIi+DLCWGS JfiNOOmn5tBUiYinsVy81VuWXpFTQeKKYHR9k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=FJ7STjpiCj1PH4VjBpcHHM+0Av6GKAPpKoYy8idJ7xYfzhhJb1a9/2gdU4f6aINb97 w/lj0v4w0RJvKclxOdIKIcCWcZ1rdIu7NYThdn//e/Uje9FMIgaNiqnCrRiBWw2V7Mep jYfeEoowAPQSo7FMjlLYQuNT8g7hBiGjsVZQw= Received: by 10.150.186.11 with SMTP id j11mr942240ybf.34.1296669857036; Wed, 02 Feb 2011 10:04:17 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.150.31.5 with SMTP id e5ls579495ybe.2.p; Wed, 02 Feb 2011 10:04:16 -0800 (PST) Received: by 10.150.206.8 with SMTP id d8mr1054070ybg.10.1296669856668; Wed, 02 Feb 2011 10:04:16 -0800 (PST) Received: by 10.150.206.8 with SMTP id d8mr1054067ybg.10.1296669856639; Wed, 02 Feb 2011 10:04:16 -0800 (PST) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by gmr-mx.google.com with ESMTPS id q2si4418ybe.0.2011.02.02.10.04.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 02 Feb 2011 10:04:16 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.54 is neither permitted nor denied by best guess record for domain of mroberto@cpti.cetuc.puc-rio.br) client-ip=209.85.213.54; Received: by ywp6 with SMTP id 6so121257ywp.13 for ; Wed, 02 Feb 2011 10:04:16 -0800 (PST) Received: by 10.90.28.17 with SMTP id b17mr12678701agb.128.1296669856192; Wed, 02 Feb 2011 10:04:16 -0800 (PST) Received: from localhost.localdomain ([139.82.178.36]) by mx.google.com with ESMTPS id u10sm3559844yba.13.2011.02.02.10.04.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 02 Feb 2011 10:04:15 -0800 (PST) From: Marcelo Roberto Jimenez 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 Subject: [rtc-linux] [PATCH] RTC: Prevents a division by zero in kernel code. Date: Wed, 2 Feb 2011 16:04:02 -0200 Message-Id: <1296669842-32611-1-git-send-email-mroberto@cpti.cetuc.puc-rio.br> X-Mailer: git-send-email 1.7.3.4 X-Original-Sender: mroberto@cpti.cetuc.puc-rio.br X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.213.54 is neither permitted nor denied by best guess record for domain of mroberto@cpti.cetuc.puc-rio.br) smtp.mail=mroberto@cpti.cetuc.puc-rio.br Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , 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;