Sfoglia il codice sorgente

tty_ioctl: locking for tty_wait_until_sent

This function still depends on the big kernel lock in some cases.  Push
locking into the function ready for removal of the BKL from ioctl call paths.

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Alan Cox 17 anni fa
parent
commit
0ee9cbb3c7
1 ha cambiato i file con 7 aggiunte e 4 eliminazioni
  1. 7 4
      drivers/char/tty_ioctl.c

+ 7 - 4
drivers/char/tty_ioctl.c

@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/bitops.h>
 #include <linux/mutex.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 
 #include <asm/io.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
@@ -61,11 +62,13 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
 		return;
 		return;
 	if (!timeout)
 	if (!timeout)
 		timeout = MAX_SCHEDULE_TIMEOUT;
 		timeout = MAX_SCHEDULE_TIMEOUT;
+	lock_kernel();
 	if (wait_event_interruptible_timeout(tty->write_wait,
 	if (wait_event_interruptible_timeout(tty->write_wait,
-			!tty->driver->chars_in_buffer(tty), timeout) < 0)
-		return;
-	if (tty->driver->wait_until_sent)
-		tty->driver->wait_until_sent(tty, timeout);
+			!tty->driver->chars_in_buffer(tty), timeout) >= 0) {
+		if (tty->driver->wait_until_sent)
+			tty->driver->wait_until_sent(tty, timeout);
+	}
+	unlock_kernel();
 }
 }
 EXPORT_SYMBOL(tty_wait_until_sent);
 EXPORT_SYMBOL(tty_wait_until_sent);