mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
printk: fix print_time bug when run dmesg [1/1]
PD#SWPL-4900 Problem: printk_prefix() passes NULL buf to print_time() to get the length of the time prefix; when printk times are enable, the current code just return "snprint(NULL, 0, "[%5lu.000000]", (unsigned long)ts)" but in the SMP case, we add cpu core id at the end of time prefix, the format is "[%5lu, %06lu@%d]", this gives a wrong size(shorter). this will make buf get out of boundary, when run dmesg. Solution: replace [%5lu.000000] with [%5lu.000000@0] Verify: g12a-u200 Change-Id: Ic74b9f466b5af5aac7e6569a1afc7a46d9594050 Signed-off-by: Jianxiong Pan <jianxiong.pan@amlogic.com>
This commit is contained in:
@@ -1194,7 +1194,11 @@ static size_t print_time(u64 ts, char *buf)
|
||||
rem_nsec = do_div(ts, 1000000000);
|
||||
|
||||
if (!buf)
|
||||
#ifdef CONFIG_AMLOGIC_MODIFY
|
||||
return snprintf(NULL, 0, "[%5lu.000000@0] ", (unsigned long)ts);
|
||||
#else
|
||||
return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && defined(CONFIG_AMLOGIC_DRIVER)
|
||||
return sprintf(buf, "[%5lu.%06lu@%d] ",
|
||||
|
||||
Reference in New Issue
Block a user