drivers/char/vt_ioctl.c: fix VT_OPENQRY error value
authorGraham Gower <graham.gower@gmail.com>
Wed, 27 Oct 2010 22:33:00 +0000 (15:33 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Dec 2010 21:24:17 +0000 (13:24 -0800)
commit 1e0ad2881d50becaeea70ec696a80afeadf944d2 upstream.

When all VT's are in use, VT_OPENQRY casts -1 to unsigned char before
returning it to userspace as an int.  VT255 is not the next available
console.

Signed-off-by: Graham Gower <graham.gower@gmail.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/char/vt_ioctl.c

index c904e9a..91d5e90 100644 (file)
@@ -371,6 +371,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
        struct kbd_struct * kbd;
        unsigned int console;
        unsigned char ucval;
+       unsigned int uival;
        void __user *up = (void __user *)arg;
        int i, perm;
        int ret = 0;
@@ -516,7 +517,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
                break;
 
        case KDGETMODE:
-               ucval = vc->vc_mode;
+               uival = vc->vc_mode;
                goto setint;
 
        case KDMAPDISP:
@@ -554,7 +555,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
                break;
 
        case KDGKBMODE:
-               ucval = ((kbd->kbdmode == VC_RAW) ? K_RAW :
+               uival = ((kbd->kbdmode == VC_RAW) ? K_RAW :
                                 (kbd->kbdmode == VC_MEDIUMRAW) ? K_MEDIUMRAW :
                                 (kbd->kbdmode == VC_UNICODE) ? K_UNICODE :
                                 K_XLATE);
@@ -576,9 +577,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
                break;
 
        case KDGKBMETA:
-               ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
+               uival = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
        setint:
-               ret = put_user(ucval, (int __user *)arg);
+               ret = put_user(uival, (int __user *)arg);
                break;
 
        case KDGETKEYCODE:
@@ -808,7 +809,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
                for (i = 0; i < MAX_NR_CONSOLES; ++i)
                        if (! VT_IS_IN_USE(i))
                                break;
-               ucval = i < MAX_NR_CONSOLES ? (i+1) : -1;
+               uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
                goto setint;             
 
        /*