]> Pileus Git - ~andy/linux/blobdiff - drivers/tty/vt/selection.c
Merge branch 'x86-ras-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~andy/linux] / drivers / tty / vt / selection.c
index 2ca8d6b6514cb31c13751a6dc835ab1e48ffbbe8..ea27804d87af9ec2485b1043f8ad97b30c05713f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/selection.h>
 #include <linux/tiocl.h>
 #include <linux/console.h>
+#include <linux/tty_flip.h>
 
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
 #define isspace(c)     ((c) == ' ')
@@ -346,8 +347,8 @@ int paste_selection(struct tty_struct *tty)
        console_unlock();
 
        ld = tty_ldisc_ref_wait(tty);
+       tty_buffer_lock_exclusive(&vc->port);
 
-       /* FIXME: this is completely unsafe */
        add_wait_queue(&vc->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);
@@ -363,6 +364,7 @@ int paste_selection(struct tty_struct *tty)
        remove_wait_queue(&vc->paste_wait, &wait);
        __set_current_state(TASK_RUNNING);
 
+       tty_buffer_unlock_exclusive(&vc->port);
        tty_ldisc_deref(ld);
        return 0;
 }