public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] timekeeping: check params before use them
@ 2014-03-27  8:12 Neil Zhang
  2014-03-27 17:26 ` John Stultz
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Zhang @ 2014-03-27  8:12 UTC (permalink / raw)
  To: john.stultz, tglx; +Cc: linux-kernel, Neil Zhang

Sometimes we won't need all the information from
get_xtime_and_monotonic_and_sleep_offset(),
so let's check the params before assign the value to them.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
---
 kernel/time/timekeeping.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 0aa4ce8..f0e8f53 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1598,9 +1598,12 @@ void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
 
 	do {
 		seq = read_seqcount_begin(&timekeeper_seq);
-		*xtim = tk_xtime(tk);
-		*wtom = tk->wall_to_monotonic;
-		*sleep = tk->total_sleep_time;
+		if (xtim)
+			*xtim = tk_xtime(tk);
+		if (wtom)
+			*wtom = tk->wall_to_monotonic;
+		if (sleep)
+			*sleep = tk->total_sleep_time;
 	} while (read_seqcount_retry(&timekeeper_seq, seq));
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-28  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27  8:12 [PATCH] timekeeping: check params before use them Neil Zhang
2014-03-27 17:26 ` John Stultz
2014-03-28  1:13   ` Neil Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox