From patchwork Wed Dec 17 03:15:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyogi Gim X-Patchwork-Id: 422165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-vc0-x23a.google.com (mail-vc0-x23a.google.com [IPv6:2607:f8b0:400c:c03::23a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F2F091400D2 for ; Wed, 17 Dec 2014 14:17:10 +1100 (AEDT) Received: by mail-vc0-f186.google.com with SMTP id im6sf2193103vcb.3 for ; Tue, 16 Dec 2014 19:17:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent: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; bh=qPvoXO/8uEjjD/I4DR1VGhdGJTPnjZ3LsgoQQ+wHWxw=; b=QmVIVJJNt1BuXuS+8kuRC+mfDvajys4TIZKIptxbvq/6yAVXcVIuk0ApQ0A8hBeE3O qWtomCsWS7bftKbfQZjFFxkBnD10fcTWI9bYhkpQFXrI8hU7F7UtKDHYUi0cgAgePaCk Ngv4yJsV9ksdsRmGZakO2JDy2P+2e1vjmZjj5tiVgiiCkAaUEoFu2JdD1pcbbmm/94+z jXu5dqUdVdFRBxVeCe/GPsyfEgcko0m951zCI+B5fKVBn+/SJVCusM3j7GXsMosf9DRJ tT9nyNzkURDbeRH5kBIvS4X1rgmBgwHpJ/IpyFK2Pnwg6SZs/UKiwr51AgAfD2sT9ONl 12yw== X-Received: by 10.140.33.229 with SMTP id j92mr291815qgj.7.1418786227008; Tue, 16 Dec 2014 19:17:07 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.140.82.209 with SMTP id h75ls993879qgd.32.gmail; Tue, 16 Dec 2014 19:17:06 -0800 (PST) X-Received: by 10.236.110.7 with SMTP id t7mr34178919yhg.29.1418786226771; Tue, 16 Dec 2014 19:17:06 -0800 (PST) Received: from lgeamrelo01.lge.com (lgeamrelo01.lge.com. [156.147.1.125]) by gmr-mx.google.com with ESMTP id tv3si349512pbc.1.2014.12.16.19.17.05 for ; Tue, 16 Dec 2014 19:17:06 -0800 (PST) Received-SPF: pass (google.com: domain of hyogi.gim@lge.com designates 156.147.1.125 as permitted sender) client-ip=156.147.1.125; Received: from unknown (HELO localhost) (165.186.175.61) by 156.147.1.125 with ESMTP; 17 Dec 2014 12:16:59 +0900 X-Original-SENDERIP: 165.186.175.61 X-Original-MAILFROM: hyogi.gim@lge.com Date: Wed, 17 Dec 2014 12:15:24 +0900 From: Hyogi Gim To: a.zummo@towertech.it, akpm@linux-foundation.org Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [rtc-linux] [PATCH] drivers/rtc/interface.c: check the error after __rtc_read_time() Message-ID: <20141217031524.GA22361@lge.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Original-Sender: hyogi.gim@lge.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of hyogi.gim@lge.com designates 156.147.1.125 as permitted sender) smtp.mail=hyogi.gim@lge.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add the verification code for returned __rtc_read_time() error in rtc_update_irq_enable() and rtc_timer_do_work(). Signed-off-by: Hyogi Gim --- drivers/rtc/interface.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 45bfc28ee..fa1f119 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -489,7 +489,10 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) struct rtc_time tm; ktime_t now, onesec; - __rtc_read_time(rtc, &tm); + err = __rtc_read_time(rtc, &tm); + if (err < 0) + goto out; + onesec = ktime_set(1, 0); now = rtc_tm_to_ktime(tm); rtc->uie_rtctimer.node.expires = ktime_add(now, onesec); @@ -867,13 +870,17 @@ void rtc_timer_do_work(struct work_struct *work) struct timerqueue_node *next; ktime_t now; struct rtc_time tm; + int err = 0; struct rtc_device *rtc = container_of(work, struct rtc_device, irqwork); mutex_lock(&rtc->ops_lock); again: - __rtc_read_time(rtc, &tm); + err = __rtc_read_time(rtc, &tm); + if (err < 0) + goto out; + now = rtc_tm_to_ktime(tm); while ((next = timerqueue_getnext(&rtc->timerqueue))) { if (next->expires.tv64 > now.tv64) @@ -898,7 +905,6 @@ again: /* Set next alarm */ if (next) { struct rtc_wkalrm alarm; - int err; int retry = 3; alarm.time = rtc_ktime_to_tm(next->expires); @@ -920,6 +926,7 @@ reprogram: } else rtc_alarm_disable(rtc); +out: pm_relax(rtc->dev.parent); mutex_unlock(&rtc->ops_lock); }