Re: [PATCH][RESEND 3] disassociate_ctty SMP fix

From: Russell King (rmk@arm.linux.org.uk)
Date: Wed Feb 05 2003 - 11:49:37 EST


Ok, here's my proposed fix, which appears to work with preempt. I haven't
tested on non-preempt, nor (obviously since its from me) SMP. However,
I forsee no problems caused by this change.

release_dev() sets filp->private_data to NULL when the tty layer has
done with the file descriptor. However, it remains on the tty_files
list until __fput completes.

--- orig/drivers/char/tty_io.c Fri Jan 17 10:39:10 2003
+++ linux/drivers/char/tty_io.c Wed Feb 5 16:38:23 2003
@@ -442,6 +442,13 @@
         file_list_lock();
         for (l = tty->tty_files.next; l != &tty->tty_files; l = l->next) {
                 struct file * filp = list_entry(l, struct file, f_list);
+ /*
+ * If this file descriptor has been closed, ignore it; it
+ * will be going away shortly. (We don't test filp->f_count
+ * for zero since that could open another race.) --rmk
+ */
+ if (filp->private_data == NULL)
+ continue;
                 if (IS_CONSOLE_DEV(filp->f_dentry->d_inode->i_rdev) ||
                     IS_SYSCONS_DEV(filp->f_dentry->d_inode->i_rdev)) {
                         cons_filp = filp;

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html

- 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/



This archive was generated by hypermail 2b29 : Fri Feb 07 2003 - 22:00:17 EST