mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hyogi Gim <hyogi.gim@lge.com>
To: John Stultz <john.stultz@linaro.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Alessandro Zummo <a.zummo@towertech.it>
Cc: linux-kernel@vger.kernel.org, Hyogi Gim <hyogi.gim@lge.com>
Subject: [PATCH] alarmtimer: Add the verification code for rtc device error.
Date: Fri, 11 Jul 2014 10:24:14 +0900	[thread overview]
Message-ID: <1405041854-17902-1-git-send-email-hyogi.gim@lge.com> (raw)

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 <hyogi.gim@lge.com>
---
 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)
-- 
1.8.3.2


             reply	other threads:[~2014-07-11  1:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  1:24 Hyogi Gim [this message]
2014-07-30 17:58 ` John Stultz
2014-08-07  2:00   ` Hyogi Gim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405041854-17902-1-git-send-email-hyogi.gim@lge.com \
    --to=hyogi.gim@lge.com \
    --cc=a.zummo@towertech.it \
    --cc=john.stultz@linaro.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®