Messages in this thread Patch in this message | | | From | Neil Zhang <> | Subject | [PATCH] timekeeping: check params before use them | Date | Thu, 27 Mar 2014 16:12:58 +0800 |
| |
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
| |