aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r--drivers/char/tty_io.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 18085a20df23..b4f37c65b95c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2740,18 +2740,21 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
2740 * @tty; tty 2740 * @tty; tty
2741 * @arg: user buffer for result 2741 * @arg: user buffer for result
2742 * 2742 *
2743 * Copies the kernel idea of the window size into the user buffer. No 2743 * Copies the kernel idea of the window size into the user buffer.
2744 * locking is done.
2745 * 2744 *
2746 * FIXME: Returning random values racing a window size set is wrong 2745 * Locking: tty->termios_sem is taken to ensure the winsize data
2747 * should lock here against that 2746 * is consistent.
2748 */ 2747 */
2749 2748
2750static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg) 2749static int tiocgwinsz(struct tty_struct *tty, struct winsize __user * arg)
2751{ 2750{
2752 if (copy_to_user(arg, &tty->winsize, sizeof(*arg))) 2751 int err;
2753 return -EFAULT; 2752
2754 return 0; 2753 down(&tty->termios_sem);
2754 err = copy_to_user(arg, &tty->winsize, sizeof(*arg));
2755 up(&tty->termios_sem);
2756
2757 return err ? -EFAULT: 0;
2755} 2758}
2756 2759
2757/** 2760/**