Skip to contentSkip to conversation

console close race fix

PATCH New Robert Love 1 participant 1 message Dec 9, 2001 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 console close race fix

Marcelo,

The attached is a fix originally by Andrew Morton and discovered by the preempt-kernel patch. It is in Alan's tree but was never merged into Linus's.

There is a race between con_close and con_flush_chars. n_tty_receive_buf writes to the tty queue and then flushes it via con_flush_chars. If the console closes in between these operations, con_flush_char barfs.

Please, for all that is righteous, apply.

Robert Love

drivers/char/console.c +7 -1
diff -urN linux-2.4.17-pre7/drivers/char/console.c linux/drivers/char/console.c
@@ -2356,8 +2356,14 @@
 		return;
 
 	pm_access(pm_con);
+	
+	/*
+	 * If we raced with con_close(), `vt' may be null.
+	 * Hence this bandaid.   - akpm
+	 */
 	acquire_console_sem();
-	set_cursor(vt->vc_num);
+	if (vt)
+		set_cursor(vt->vc_num);
 	release_console_sem();
 }