Skip to content

Commit 000d371

Browse files
SevenQCrostedt
authored andcommitted
printk: Enhance the condition check of msleep in pr_flush()
[ Upstream commit 83e9288d9c4295d1195e9d780fcbc42c72ba4a83 ] There is msleep in pr_flush(). If call WARN() in the early boot stage such as in early_initcall, pr_flush() will run into msleep when process scheduler is not ready yet. And then the system will sleep forever. Before the system_state is SYSTEM_RUNNING, make sure DO NOT sleep in pr_flush(). Fixes: c0b395bd0fe3("printk: add pr_flush()") Signed-off-by: Chao Qin <[email protected]> Signed-off-by: Lili Li <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: John Ogness <[email protected]> Signed-off-by: John Ogness <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 0c75ad6 commit 000d371

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/printk/printk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3545,7 +3545,9 @@ bool pr_flush(int timeout_ms, bool reset_on_progress)
35453545
u64 diff;
35463546
u64 seq;
35473547

3548-
may_sleep = (preemptible() && !in_softirq());
3548+
may_sleep = (preemptible() &&
3549+
!in_softirq() &&
3550+
system_state >= SYSTEM_RUNNING);
35493551

35503552
seq = prb_next_seq(prb);
35513553

0 commit comments

Comments
 (0)