aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/pstore/ram.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index ec0e1da0596a..c5c685589e36 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -345,19 +345,15 @@ out:
345static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz, 345static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
346 struct pstore_record *record) 346 struct pstore_record *record)
347{ 347{
348 char *hdr; 348 char hdr[36]; /* "===="(4), %lld(20), "."(1), %06lu(6), "-%c\n"(3) */
349 size_t len; 349 size_t len;
350 350
351 hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lld.%06lu-%c\n", 351 len = scnprintf(hdr, sizeof(hdr),
352 RAMOOPS_KERNMSG_HDR "%lld.%06lu-%c\n",
352 (time64_t)record->time.tv_sec, 353 (time64_t)record->time.tv_sec,
353 record->time.tv_nsec / 1000, 354 record->time.tv_nsec / 1000,
354 record->compressed ? 'C' : 'D'); 355 record->compressed ? 'C' : 'D');
355 if (WARN_ON_ONCE(!hdr))
356 return 0;
357
358 len = strlen(hdr);
359 persistent_ram_write(prz, hdr, len); 356 persistent_ram_write(prz, hdr, len);
360 kfree(hdr);
361 357
362 return len; 358 return len;
363} 359}