Commit 1e0ad288 authored by Graham Gower's avatar Graham Gower Committed by Linus Torvalds

drivers/char/vt_ioctl.c: fix VT_OPENQRY error value

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: default avatarGraham Gower <graham.gower@gmail.com>
Cc: Greg KH <greg@kroah.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8881cdce
...@@ -503,6 +503,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -503,6 +503,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
struct kbd_struct * kbd; struct kbd_struct * kbd;
unsigned int console; unsigned int console;
unsigned char ucval; unsigned char ucval;
unsigned int uival;
void __user *up = (void __user *)arg; void __user *up = (void __user *)arg;
int i, perm; int i, perm;
int ret = 0; int ret = 0;
...@@ -657,7 +658,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -657,7 +658,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
break; break;
case KDGETMODE: case KDGETMODE:
ucval = vc->vc_mode; uival = vc->vc_mode;
goto setint; goto setint;
case KDMAPDISP: case KDMAPDISP:
...@@ -695,7 +696,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -695,7 +696,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
break; break;
case KDGKBMODE: 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_MEDIUMRAW) ? K_MEDIUMRAW :
(kbd->kbdmode == VC_UNICODE) ? K_UNICODE : (kbd->kbdmode == VC_UNICODE) ? K_UNICODE :
K_XLATE); K_XLATE);
...@@ -717,9 +718,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -717,9 +718,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
break; break;
case KDGKBMETA: 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: setint:
ret = put_user(ucval, (int __user *)arg); ret = put_user(uival, (int __user *)arg);
break; break;
case KDGETKEYCODE: case KDGETKEYCODE:
...@@ -949,7 +950,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -949,7 +950,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
for (i = 0; i < MAX_NR_CONSOLES; ++i) for (i = 0; i < MAX_NR_CONSOLES; ++i)
if (! VT_IS_IN_USE(i)) if (! VT_IS_IN_USE(i))
break; break;
ucval = i < MAX_NR_CONSOLES ? (i+1) : -1; uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
goto setint; goto setint;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment