public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] 2.5: console close race fix
Date: 25 Jan 2002 18:21:09 -0500	[thread overview]
Message-ID: <1012000869.3501.97.camel@phantasy> (raw)

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();
 }
 

 


                 reply	other threads:[~2002-01-25 23:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1012000869.3501.97.camel@phantasy \
    --to=rml@tech9.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox