All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.5: console close race fix
@ 2002-01-25 23:21 Robert Love
  0 siblings, 0 replies; only message in thread
From: Robert Love @ 2002-01-25 23:21 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Linus,

There is a race between con_flush_chars and con_close.  I first
discovered it with the preemptive kernel patch, but it is a general SMP
race.  The idea for the fix is originally by Andrew Morton.

This fix is in 2.4.  Please, apply.

	Robert Love

diff -urN linux-2.5.3-pre5/drivers/char/console.c linux/drivers/char/console.c
--- linux-2.5.3-pre5/drivers/char/console.c	Thu Jan 24 17:02:57 2002
+++ linux/drivers/char/console.c	Fri Jan 25 18:12:36 2002
@@ -2349,14 +2349,18 @@
 
 static void con_flush_chars(struct tty_struct *tty)
 {
-	struct vt_struct *vt = (struct vt_struct *)tty->driver_data;
+	struct vt_struct *vt;
 
 	if (in_interrupt())	/* from flush_to_ldisc */
 		return;
 
 	pm_access(pm_con);
+	
+	/* if we race with con_close(), vt may be null */
 	acquire_console_sem();
-	set_cursor(vt->vc_num);
+	vt = (struct vt_struct *)tty->driver_data;
+	if (vt)
+		set_cursor(vt->vc_num);
 	release_console_sem();
 }
 

 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-01-25 23:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-25 23:21 [PATCH] 2.5: console close race fix Robert Love

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.