From patchwork Tue Jul 15 08:25:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyogi Gim X-Patchwork-Id: 33647 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DB5B20CAD for ; Tue, 15 Jul 2014 08:27:34 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id y10sf10271215pdj.0 for ; Tue, 15 Jul 2014 01:27:33 -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=W35jqkjvaZ3PAoIF8dLVEfDQGlw5M6aPHyN24Kdsftc=; b=JmMayrH4Y6MEY/Z3+ZbELCp8XXzKtUB9fiHylZCQybjCyr5Y5xqrsfeyKZx6kd0iyv ZA8uiZ/ErO2z3Qnyj14Tgs8DnmpmWDgkTgGUjtXECfxhcDuTKtTN947zvdrKBIrVTsJV TFR3hdM8vRT43KRt1pbiTMqG+4uo56SlJFyq+OcZ8ns28dpKk25aJYAbWaCGasiFKlRn 42ytLAZjFRndk/j08SDYnABGjr+SDW4O1Ay287EtHoY+13fNcP56b5atnQGgSIUrWcKH w6sNQuwrAVLwm9fLPZsL4WXNU67zrGLtKPUletZm+jvY9hBNLHCjHONMGo74k48sPg0a 60MA== X-Gm-Message-State: ALoCoQnafB6owARuN5q0gmED6femcI6tqiF1kEyWIxG8iUnMSG6WsmnAQl+0QNd+Xf/vGxxhsYHO X-Received: by 10.66.65.109 with SMTP id w13mr10582186pas.21.1405412853644; Tue, 15 Jul 2014 01:27:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.6 with SMTP id u6ls24370qgu.59.gmail; Tue, 15 Jul 2014 01:27:33 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr6689717vcb.28.1405412853524; Tue, 15 Jul 2014 01:27:33 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id ke8si6373848vec.83.2014.07.15.01.27.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 01:27:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hq11so9565850vcb.13 for ; Tue, 15 Jul 2014 01:27:33 -0700 (PDT) X-Received: by 10.220.203.134 with SMTP id fi6mr21038303vcb.18.1405412853429; Tue, 15 Jul 2014 01:27:33 -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 tc5csp196351vcb; Tue, 15 Jul 2014 01:27:33 -0700 (PDT) X-Received: by 10.70.91.170 with SMTP id cf10mr21506112pdb.72.1405412852657; Tue, 15 Jul 2014 01:27:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qz9si11191796pab.152.2014.07.15.01.27.31; Tue, 15 Jul 2014 01:27:31 -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 S1758081AbaGOI1V (ORCPT + 28 others); Tue, 15 Jul 2014 04:27:21 -0400 Received: from lgeamrelo01.lge.com ([156.147.1.125]:58043 "EHLO lgeamrelo01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751256AbaGOI1R (ORCPT ); Tue, 15 Jul 2014 04:27:17 -0400 Received: from unknown (HELO localhost.localdomain) (165.186.175.61) by 156.147.1.125 with ESMTP; 15 Jul 2014 17:27:05 +0900 X-Original-SENDERIP: 165.186.175.61 X-Original-MAILFROM: hyogi.gim@lge.com From: Hyogi Gim To: Alessandro Zummo Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Hyogi Gim Subject: [PATCH] driver/rtc/class.c: check the error after rtc_read_time() Date: Tue, 15 Jul 2014 17:25:23 +0900 Message-Id: <1405412723-10062-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.182 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 rtc_suspend() and rtc_resume(), the error after rtc_read_time() is not checked. If rtc device fail to read time, we cannot guarantee the following process. Add the verification code for returned rtc_read_time() error. Signed-off-by: Hyogi Gim --- drivers/rtc/class.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 589351e..38e26be 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -53,6 +53,7 @@ static int rtc_suspend(struct device *dev) struct rtc_device *rtc = to_rtc_device(dev); struct rtc_time tm; struct timespec delta, delta_delta; + int err; if (has_persistent_clock()) return 0; @@ -61,7 +62,12 @@ static int rtc_suspend(struct device *dev) return 0; /* snapshot the current RTC and system time at suspend*/ - rtc_read_time(rtc, &tm); + err = rtc_read_time(rtc, &tm); + if (err < 0) { + pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); + return 0; + } + getnstimeofday(&old_system); rtc_tm_to_time(&tm, &old_rtc.tv_sec); @@ -94,6 +100,7 @@ static int rtc_resume(struct device *dev) struct rtc_time tm; struct timespec new_system, new_rtc; struct timespec sleep_time; + int err; if (has_persistent_clock()) return 0; @@ -104,7 +111,12 @@ static int rtc_resume(struct device *dev) /* snapshot the current rtc and system time at resume */ getnstimeofday(&new_system); - rtc_read_time(rtc, &tm); + err = rtc_read_time(rtc, &tm); + if (err < 0) { + pr_debug("%s: fail to read rtc time\n", dev_name(&rtc->dev)); + return 0; + } + if (rtc_valid_tm(&tm) != 0) { pr_debug("%s: bogus resume time\n", dev_name(&rtc->dev)); return 0;