From patchwork Fri Jul 11 01:24:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyogi Gim X-Patchwork-Id: 33469 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD343203C0 for ; Fri, 11 Jul 2014 01:25:59 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id at20sf2233715iec.3 for ; Thu, 10 Jul 2014 18:25:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=vxkkFLUL2heGLb7gxkFVN9RLEd3q1rLnJfGQIcMx2RM=; b=LKxfGuLbYOgjGQpOO9Qx6OOvuFj5X+pbKnTz71xJf9gGMKr7JF+pDq1v6b31hiQx+h hKJflixwpvywwO+iLjyxYMorvT5zTVHzPJPYY8HMRdYVKRXRMnREHOyxdjn622XPnA3S 2+MPeu4MybnB7vLBJy5Fb8GefupbS1LefHnJqYD/54iGv2/1QnLHbW4C1l++vETkurx6 WYoo2M1MHE3Y9SeyMRjEJ+DSY3d6R3hHqMtsWWOemJEWjemAt86yZgsLcrOXcl5DoHi+ YA0zOOfZwZMkNnvrh7xVVzyNGc3bM15I9HrImNU9JVQbee9GHaggmlWX5RoF9U7hdubV dfAA== X-Gm-Message-State: ALoCoQmtxSBS9cczGELJ3++6HEhoupP/tpKUchXwvEP1ScjaKLHvULrTKLilwkYTB7cnSegQi1ED X-Received: by 10.43.172.194 with SMTP id nz2mr652605icc.2.1405041959263; Thu, 10 Jul 2014 18:25:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.3 with SMTP id t3ls247463qga.82.gmail; Thu, 10 Jul 2014 18:25:59 -0700 (PDT) X-Received: by 10.220.69.68 with SMTP id y4mr6632497vci.21.1405041959117; Thu, 10 Jul 2014 18:25:59 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id u8si626758vey.74.2014.07.10.18.25.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 18:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id im17so786362vcb.11 for ; Thu, 10 Jul 2014 18:25:58 -0700 (PDT) X-Received: by 10.52.7.163 with SMTP id k3mr3030432vda.58.1405041958739; Thu, 10 Jul 2014 18:25:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp181533vcb; Thu, 10 Jul 2014 18:25:58 -0700 (PDT) X-Received: by 10.66.158.10 with SMTP id wq10mr51410807pab.32.1405041957918; Thu, 10 Jul 2014 18:25:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lx8si768318pab.115.2014.07.10.18.25.57; Thu, 10 Jul 2014 18:25:57 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbaGKBZs (ORCPT + 28 others); Thu, 10 Jul 2014 21:25:48 -0400 Received: from lgeamrelo01.lge.com ([156.147.1.125]:54498 "EHLO lgeamrelo01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751394AbaGKBZr (ORCPT ); Thu, 10 Jul 2014 21:25:47 -0400 Received: from unknown (HELO localhost.localdomain) (165.186.175.61) by 156.147.1.125 with ESMTP; 11 Jul 2014 10:25:43 +0900 X-Original-SENDERIP: 165.186.175.61 X-Original-MAILFROM: hyogi.gim@lge.com From: Hyogi Gim To: John Stultz , KOSAKI Motohiro , Alessandro Zummo Cc: linux-kernel@vger.kernel.org, Hyogi Gim Subject: [PATCH] alarmtimer: Add the verification code for rtc device error. Date: Fri, 11 Jul 2014 10:24:14 +0900 Message-Id: <1405041854-17902-1-git-send-email-hyogi.gim@lge.com> X-Mailer: git-send-email 1.8.3.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hyogi.gim@lge.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In alarmtimer_suspend(), the error after rtc_read_time() is not checked. If rtc device fail to read rtc time, we cannot ensure the following process. Furthermore, the return value of rtc_timer_start() needs to distinguish -ETIME and other rtc device error. If the error is relevant to rtc device, suspend is failed unintentionally. In this case, it just returns zero for a stable suspend. Otherwise, in the worst case, suspend will fail continually. So, this patch verifies the rtc device error in alarmtimer_suspend(). it includes "rtc_err goto" statement instead of a direct "return 0" to clarify the rtc device error. Signed-off-by: Hyogi Gim --- kernel/time/alarmtimer.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 88c9c65..8cc43b8 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -261,15 +261,23 @@ static int alarmtimer_suspend(struct device *dev) /* Setup an rtc timer to fire that far in the future */ rtc_timer_cancel(rtc, &rtctimer); - rtc_read_time(rtc, &tm); + ret = rtc_read_time(rtc, &tm); + if (ret < 0) + goto rtc_err; now = rtc_tm_to_ktime(tm); now = ktime_add(now, min); /* Set alarm, if in the past reject suspend briefly to handle */ ret = rtc_timer_start(rtc, &rtctimer, now, ktime_set(0, 0)); - if (ret < 0) + if (ret == -ETIME) __pm_wakeup_event(ws, MSEC_PER_SEC); + else if (ret < 0) + goto rtc_err; + return ret; + +rtc_err: + return 0; } #else static int alarmtimer_suspend(struct device *dev)