]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
tty_ioctl: locking for tty_wait_until_sent
authorAlan Cox <alan@lxorguk.ukuu.org.uk>
Wed, 30 Apr 2008 07:53:32 +0000 (00:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Apr 2008 15:29:41 +0000 (08:29 -0700)
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>
drivers/char/tty_ioctl.c

index d6353d89b451aa25ba04aedabc32f9cdbeb5f197..851cfcd2702a6ff19e85ed68e3fc50e1a07a4951 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -61,11 +62,13 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
                return;
        if (!timeout)
                timeout = MAX_SCHEDULE_TIMEOUT;
+       lock_kernel();
        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);