diff options
author | Kees Cook <keescook@chromium.org> | 2012-11-19 10:26:16 -0800 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2013-01-15 18:16:02 -0800 |
commit | 1e817fb62cd185a2232ad4302579491805609489 (patch) | |
tree | d4155fb65a9fb32cd9236405a8b7534f39c293b9 /fs | |
parent | 9c3f9e281697d02889c3b08922f3b30be75f56c2 (diff) | |
download | op-kernel-dev-1e817fb62cd185a2232ad4302579491805609489.zip op-kernel-dev-1e817fb62cd185a2232ad4302579491805609489.tar.gz |
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')
-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 1a4f6da..dacfe78 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); |