linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: don't unconditionally shortcut print_time()
@ 2018-11-24 10:50 Tetsuo Handa
  2018-11-24 14:28 ` [PATCH] printk: deduplicate print_prefix() calls Tetsuo Handa
  2018-11-29 14:19 ` [PATCH] printk: don't unconditionally shortcut print_time() Petr Mladek
  0 siblings, 2 replies; 18+ messages in thread
From: Tetsuo Handa @ 2018-11-24 10:50 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky, Steven Rostedt
  Cc: linux-kernel, Tetsuo Handa

Since /sys/module/printk/parameters/time can change from N to Y between
"msg_print_text() called print_prefix() with buf == NULL" and
"msg_print_text() again calls print_prefix() with buf != NULL", it is not
safe for print_time() to unconditionally return 0 if printk_time == false.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 kernel/printk/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 5c2079d..df7ced0 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1230,7 +1230,7 @@ static size_t print_time(u64 ts, char *buf)
 {
 	unsigned long rem_nsec;
 
-	if (!printk_time)
+	if (!printk_time && buf)
 		return 0;
 
 	rem_nsec = do_div(ts, 1000000000);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-12-04 10:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-24 10:50 [PATCH] printk: don't unconditionally shortcut print_time() Tetsuo Handa
2018-11-24 14:28 ` [PATCH] printk: deduplicate print_prefix() calls Tetsuo Handa
2018-11-26  7:56   ` Sergey Senozhatsky
2018-11-26 10:21     ` Tetsuo Handa
2018-11-29 14:35   ` Petr Mladek
2018-11-29 14:19 ` [PATCH] printk: don't unconditionally shortcut print_time() Petr Mladek
2018-11-30  2:26   ` Tetsuo Handa
2018-11-30 12:30     ` Petr Mladek
2018-11-30 14:33       ` Tetsuo Handa
2018-12-01 11:30         ` Tetsuo Handa
2018-12-02  5:02           ` Tetsuo Handa
2018-12-03 13:16             ` Petr Mladek
2018-12-04  2:56             ` Sergey Senozhatsky
2018-12-04 10:06               ` Tetsuo Handa
2018-12-04 10:59                 ` Sergey Senozhatsky
2018-12-03 14:14         ` Petr Mladek
2018-12-03 15:00           ` Tetsuo Handa
2018-11-30  4:24   ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).