Skip to contentSkip to conversation

kernel/printk: check return value of console_trylock()

PATCH In review Li Zhong 2 participants 3 messages Sep 17, 2022 – Sep 19, 2022 Printk

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 kernel/printk: check return value of console_trylock()

Check the console_trylock() return value in case it fails.

---
 kernel/printk/printk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/printk/printk.c +2 -1
index a1a81fd9889b..2c6a0484315b 100644
@@ -2937,7 +2937,8 @@ void console_flush_on_panic(enum con_flush_mode mode)
 	 * context and we don't want to get preempted while flushing,
 	 * ensure may_schedule is cleared.
 	 */
-	console_trylock();
+	if (!console_trylock())
+		return;
 	console_may_schedule = 0;
 
 	if (mode == CONSOLE_REPLAY_ALL) {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 1 line · Li Zhong

Check the console_trylock() return value in case it fails.

[..]

kernel/printk/printk.c void console_flush_on_panic(enum con_flush_mode mode) · line 2941

Quoted 11 lines
kernel/printk/printk.c +2 -1
index a1a81fd9889b..2c6a0484315b 100644
@@ -2937,7 +2937,8 @@ void console_flush_on_panic(enum con_flush_mode mode)
 	 * context and we don't want to get preempted while flushing,
 	 * ensure may_schedule is cleared.
 	 */
-	console_trylock();
+	if (!console_trylock())
+		return;

It supposed to be ignored and the comment above (in the code) explains why: this is panic flush, we want to proceed regardless.

author
#2 lore raw
Quoted 4 lines · Sergey Senozhatsky
Quoted 1 line · Li Zhong

Check the console_trylock() return value in case it fails.

[..]

Quoted 14 lines

kernel/printk/printk.c void console_flush_on_panic(enum con_flush_mode mode) · line 2941

Quoted 11 lines
kernel/printk/printk.c +2 -1
index a1a81fd9889b..2c6a0484315b 100644
@@ -2937,7 +2937,8 @@ void console_flush_on_panic(enum con_flush_mode mode)
       * context and we don't want to get preempted while flushing,
       * ensure may_schedule is cleared.
       */
-     console_trylock();
+     if (!console_trylock())
+             return;

It supposed to be ignored and the comment above (in the code) explains why: this is panic flush, we want to proceed regardless.

Thanks for your explanation.