diff options
author | Kees Cook <keescook@chromium.org> | 2012-11-19 19:26:16 +0100 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2013-01-16 03:16:02 +0100 |
commit | 1e817fb62cd185a2232ad4302579491805609489 (patch) | |
tree | d4155fb65a9fb32cd9236405a8b7534f39c293b9 /fs/pstore | |
parent | Merge branch 'fortglx/3.8/time' of git://git.linaro.org/people/jstultz/linux ... (diff) | |
download | linux-1e817fb62cd185a2232ad4302579491805609489.tar.xz linux-1e817fb62cd185a2232ad4302579491805609489.zip |
time: create __getnstimeofday for WARNless calls
The pstore RAM backend can get called during resume, and must be defensive
against a suspended time source. Expose getnstimeofday logic that returns
an error instead of a WARN. This can be detected and the timestamp can
be zeroed out.
Reported-by: Doug Anderson <dianders@chromium.org>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r-- | fs/pstore/ram.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 1a4f6da58eab..dacfe78aee7e 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -168,12 +168,16 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz) { char *hdr; - struct timeval timestamp; + struct timespec timestamp; size_t len; - do_gettimeofday(×tamp); + /* Report zeroed timestamp if called before timekeeping has resumed. */ + if (__getnstimeofday(×tamp)) { + timestamp.tv_sec = 0; + timestamp.tv_nsec = 0; + } hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n", - (long)timestamp.tv_sec, (long)timestamp.tv_usec); + (long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000)); WARN_ON_ONCE(!hdr); len = hdr ? strlen(hdr) : 0; persistent_ram_write(prz, hdr, len); |