linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: marcelo@conectiva.com.br
Cc: gordo@pincoya.com, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@zip.com.au>
Subject: [PATCH] Re: console close race fix resend
Date: 11 Dec 2001 04:05:30 -0500	[thread overview]
Message-ID: <1008061551.815.1.camel@phantasy> (raw)
In-Reply-To: <3C15A79A.98EC0ADB@zip.com.au>
In-Reply-To: <20011210191630.A13679@furble>, <1008035512.4287.1.camel@phantasy>  <20011210191630.A13679@furble> <1008050718.4287.11.camel@phantasy>  <3C15A79A.98EC0ADB@zip.com.au>

OK, I talked to Andrew off-list and we agree his fix is more correct. 
It should be applied.  I tested it (I have a consistent method of
reproducing the race under preempt-kernel) and it works.

I rediffed it against pre8 because I had trouble applying his, oddly. 
Ignore previous patch.  Marcelo, please apply.  Seriously, this time.

	Robert Love

--- linux-2.4.17-pre8/drivers/char/console.c	Mon Dec 10 20:48:50 2001
+++ linux/drivers/char/console.c	Tue Dec 11 02:52:44 2001
@@ -100,6 +100,7 @@
 #include <linux/tqueue.h>
 #include <linux/bootmem.h>
 #include <linux/pm.h>
+#include <linux/smp_lock.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
@@ -2348,17 +2349,25 @@
 	set_leds();
 }
 
+/*
+ * we can race here against con_close, so we grab the bkl
+ * and check the pointer before calling set_cursor
+ */
 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);
+	lock_kernel();
 	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();
+	unlock_kernel();
 }
 
 /*


      parent reply	other threads:[~2001-12-11  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-11  1:51 [PATCH] console close race fix resend Robert Love
2001-12-11  3:16 ` Gordon Oliver
2001-12-11  6:05 ` Robert Love
2001-12-11  6:28   ` Andrew Morton
2001-12-11  8:54   ` Gordon Oliver
2001-12-11  9:05   ` Robert Love [this message]

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=1008061551.815.1.camel@phantasy \
    --to=rml@tech9.net \
    --cc=akpm@zip.com.au \
    --cc=gordo@pincoya.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /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;
as well as URLs for NNTP newsgroup(s).