From patchwork Wed Dec 17 00:15:59 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zummo X-Patchwork-Id: 14402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from yx-out-2122.google.com (yx-out-2122.google.com [74.125.44.24]) by ozlabs.org (Postfix) with ESMTP id 4C6F4DDDF6 for ; Wed, 17 Dec 2008 11:16:32 +1100 (EST) Received: by yx-out-2122.google.com with SMTP id 35so908344yxh.11 for ; Tue, 16 Dec 2008 16:16:31 -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 :received:from:subject:to:cc:date:message-id:user-agent:mime-version :content-type:reply-to:sender:precedence:x-google-loop:mailing-list :list-id:list-post:list-help:list-unsubscribe:x-beenthere-env :x-beenthere; bh=lr4/oSnqw2S7pEyiXilUNU1cuwJZPdgtwX4FDN735jM=; b=b82Csg2qUHuBuwdetJxeKD12vQe1F1H5SxjgArn/sBuIwlF4yEfm1s0DYsH7MiUFdH xZVrA58O6xDq+ZU6NaLHrE645IRqoqZ6/Gup3BykXo9rvfrojMWCrTLMObzYQXSamIHT QARTiy84nfpcDmCdgYj3LB6MvRhWcNIR2zFdU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results:from :subject:to:cc:date:message-id:user-agent:mime-version:content-type :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; b=2PC47mDivpB30qjuucSpFXGPcezKWck5IXCzwBSL+8a2L+c9To2vbtx8qyabhC5WyH 7zzk52ulsmozrKKHOHyV6xeyAx4hM5vGda4+il3AQQfjacjiG31+vZ4cr7b6RxOmKzao MsdmDRVJMjUDpwAGz6CyirlbFZ0IJTgOXePWg= Received: by 10.150.191.15 with SMTP id o15mr217388ybf.19.1229472988093; Tue, 16 Dec 2008 16:16:28 -0800 (PST) Received: by 10.176.101.40 with SMTP id y40gr1741yqb.0; Tue, 16 Dec 2008 16:16:28 -0800 (PST) X-Sender: a.zummo@towertech.it X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.90.33.15 with SMTP id g15mr914546agg.3.1229472986705; Tue, 16 Dec 2008 16:16:26 -0800 (PST) Received: from mx0.towertech.it (mx0.towertech.it [213.215.222.73]) by mx.google.com with SMTP id 7si3436627yxg.2.2008.12.16.16.16.25; Tue, 16 Dec 2008 16:16:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of a.zummo@towertech.it designates 213.215.222.73 as permitted sender) client-ip=213.215.222.73; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of a.zummo@towertech.it designates 213.215.222.73 as permitted sender) smtp.mail=a.zummo@towertech.it Received: (qmail 1812 invoked from network); 17 Dec 2008 01:16:24 +0100 Received: from unknown (HELO i1501.lan.towertech.it) (81.208.60.204) by mx0.towertech.it with SMTP; 17 Dec 2008 01:16:24 +0100 From: Alessandro Zummo Subject: [rtc-linux] [PATCH] rtc: rtc-isl1208: reject invalid dates To: akpm@linux-foundation.org Cc: rtc-linux@googlegroups.com, Chris Elston , Alessandro Zummo , Hebert Valerio Riedel Date: Wed, 17 Dec 2008 01:15:59 +0100 Message-ID: <20081217001559.29099.29300.stgit@i1501.lan.towertech.it> User-Agent: StGIT/0.14.2 Mime-Version: 1.0 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 From: Chris Elston This patch for the rtc-isl1208 driver makes it reject invalid dates. Please queue it for 2.6.28 if possible. Signed-off-by: Chris Elston [a.zummo@towertech.it: added comment explaining the check] Signed-off-by: Alessandro Zummo Cc: Hebert Valerio Riedel --- drivers/rtc/rtc-isl1208.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) --~--~---------~--~----~------------~-------~--~----~ 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-isl1208.c b/drivers/rtc/rtc-isl1208.c index 2cd77ab..054e052 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -328,6 +328,13 @@ isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) int sr; u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; + /* The clock has an 8 bit wide bcd-coded register (they never learn) + * for the year. tm_year is an offset from 1900 and we are interested + * in the 2000-2099 range, so any value less than 100 is invalid. + */ + if (tm->tm_year < 100) + return -EINVAL; + regs[ISL1208_REG_SC] = bin2bcd(tm->tm_sec); regs[ISL1208_REG_MN] = bin2bcd(tm->tm_min); regs[ISL1208_REG_HR] = bin2bcd(tm->tm_hour) | ISL1208_REG_HR_MIL;