From patchwork Mon Mar 2 14:41:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 23936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from mail-qy0-f40.google.com (mail-qy0-f40.google.com [209.85.221.40]) by ozlabs.org (Postfix) with ESMTP id 4D6CBDDEFD for ; Tue, 3 Mar 2009 01:41:42 +1100 (EST) Received: by qyk6 with SMTP id 6so1043494qyk.29 for ; Mon, 02 Mar 2009 06:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received :dkim-signature:domainkey-signature:received:received:message-id :date:from:user-agent:mime-version:content-type:to:cc:subject :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; bh=bT90E1R2Rx/xT8MnAjFNXrYiKeb+xE9ZWZWlW3lVef4=; b=BlsSM6sD88lVMayB1MXF3auKVFjOneZw3y6sB73IWh9LFKBzq9fBnsVUPJpSFRdi8T szkouJFNW3Mme/y8r67o8sgjiNUzwmvoC1eZ9Rjt3ohyX1fRt0NCH26AUBwuPTT3NYNz 7cvsIBlAsPUm685XhMEHjXJNwnbTBPZDQUva8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :dkim-signature:domainkey-signature:message-id:date:from:user-agent :mime-version:content-type:to:cc:subject:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=O2dHJCLfLfyNj+Nz94LpJ8rHMSoI+O2qlCP3OOWbwMO4DJ5vCffviug9VuHKBSTlBt LNfq5KSNz01+Pbl6qLseZDGdCjkhuCiMwwHQKOyrUkTjyRSqYXADAYqA75uDs6pyDprS EvLTmLnTa1E2H1cDU7VraV5Gj2wXMDjWeQu8M= Received: by 10.224.15.17 with SMTP id i17mr647985qaa.2.1236004898587; Mon, 02 Mar 2009 06:41:38 -0800 (PST) Received: by 10.176.101.40 with SMTP id y40gr1966yqb.0; Mon, 02 Mar 2009 06:41:38 -0800 (PST) X-Sender: roel.kluin@gmail.com X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.210.35.5 with SMTP id i5mr425377ebi.0.1236004897842; Mon, 02 Mar 2009 06:41:37 -0800 (PST) Received: from mail-ew0-f173.google.com (mail-ew0-f173.google.com [209.85.219.173]) by mx.google.com with ESMTP id 16si2090584ewy.3.2009.03.02.06.41.36; Mon, 02 Mar 2009 06:41:36 -0800 (PST) Received-SPF: pass (google.com: domain of roel.kluin@gmail.com designates 209.85.219.173 as permitted sender) client-ip=209.85.219.173; Authentication-Results: mx.google.com; spf=pass (google.com: domain of roel.kluin@gmail.com designates 209.85.219.173 as permitted sender) smtp.mail=roel.kluin@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by ewy21 with SMTP id 21so1742318ewy.34 for ; Mon, 02 Mar 2009 06:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=Kix0r3sBGBkG9YSwLKn2kc+6h1mK07vuY4dqbf3AmHA=; b=SE1cWJAFqbSKjwkrwUz6h3gqxrPRTNs3eclqRgGLNLqwJcT2aGnE5MR9EjuJSfcrE5 9SKydYn7FleF2BMY6zUpP6p1lNYNgmn2U6OiGjyaJ6jIKL6y/5gBvc9dG7E+qTp40OOE REHn1fRomqUq78XyG/ovU+solTBKm/RxPl0Io= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=jGCxKh/x8/oPkB9XBvirOdfqgMpdHdEWb7m/gKU5gOb9pVKuNevC8sVWMORcZXniPC 426Gl3mvwi1oZDLNuR4vYF3655C+eWipZ/AcqnmXMxl6WsLBZsW87NL5b1628pYU+q2n wMOkYRi0WVwqYYbIV2GD4smItU5BM/+0Og3xM= Received: by 10.211.196.13 with SMTP id y13mr4810493ebp.79.1236004896785; Mon, 02 Mar 2009 06:41:36 -0800 (PST) Received: from ?192.168.1.115? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id 7sm256761eyg.57.2009.03.02.06.41.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 02 Mar 2009 06:41:36 -0800 (PST) Message-ID: <49ABF020.3070705@gmail.com> Date: Mon, 02 Mar 2009 15:41:36 +0100 From: Roel Kluin User-Agent: Thunderbird 2.0.0.18 (X11/20081105) Mime-Version: 1.0 To: a.zummo@towertech.it CC: rtc-linux@googlegroups.com, Andrew Morton Subject: [rtc-linux] [PATCH] rtc: test before subtraction on unsigned Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com please review. ------------------------------>8-------------8<--------------------------------- new_alarm is unsigned so test before the subtraction. Signed-off-by: Roel Kluin --- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~--- diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index a5b0fc0..39129cf 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c @@ -222,16 +222,16 @@ static int ds1374_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) rtc_tm_to_time(&alarm->time, &new_alarm); rtc_tm_to_time(&now, &itime); - new_alarm -= itime; - /* This can happen due to races, in addition to dates that are * truly in the past. To avoid requiring the caller to check for * races, dates in the past are assumed to be in the recent past * (i.e. not something that we'd rather the caller know about via * an error), and the alarm is set to go off as soon as possible. */ - if (new_alarm <= 0) + if (new_alarm <= itime) new_alarm = 1; + else + new_alarm -= itime; mutex_lock(&ds1374->mutex);