[PATCH] Re: console close race fix resend

Robert Love (rml@tech9.net)
11 Dec 2001 04:05:30 -0500


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

/*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/