public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/char/vt_ioctl.c: Fix VT_OPENQRY error value
@ 2010-09-03  6:31 Graham Gower
  2010-09-03  6:48 ` Graham Gower
  0 siblings, 1 reply; 2+ messages in thread
From: Graham Gower @ 2010-09-03  6:31 UTC (permalink / raw)
  To: linux-kernel

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>
--- drivers/char/vt_ioctl.c~	2010-08-11 04:07:31.000000000 +0930
+++ drivers/char/vt_ioctl.c	2010-09-03 15:12:30.000000000 +0930
@@ -503,6 +503,7 @@
 	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;
@@ -657,7 +658,7 @@
 		break;
 
 	case KDGETMODE:
-		ucval = vc->vc_mode;
+		uival = vc->vc_mode;
 		goto setint;
 
 	case KDMAPDISP:
@@ -695,7 +696,7 @@
 		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);
@@ -949,7 +950,7 @@
 		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;		 
 
 	/*

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drivers/char/vt_ioctl.c: Fix VT_OPENQRY error value
  2010-09-03  6:31 [PATCH] drivers/char/vt_ioctl.c: Fix VT_OPENQRY error value Graham Gower
@ 2010-09-03  6:48 ` Graham Gower
  0 siblings, 0 replies; 2+ messages in thread
From: Graham Gower @ 2010-09-03  6:48 UTC (permalink / raw)
  To: linux-kernel

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>
---

Sorry, I seem to have dropped a patch fragment in the previous mail.

--- drivers/char/vt_ioctl.c~	2010-08-11 04:07:31.000000000 +0930
+++ drivers/char/vt_ioctl.c	2010-09-03 16:13:59.000000000 +0930
@@ -503,6 +503,7 @@
 	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;
@@ -657,7 +658,7 @@
 		break;
 
 	case KDGETMODE:
-		ucval = vc->vc_mode;
+		uival = vc->vc_mode;
 		goto setint;
 
 	case KDMAPDISP:
@@ -695,7 +696,7 @@
 		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);
@@ -717,9 +718,9 @@
 		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:
@@ -949,7 +950,7 @@
 		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;		 
 
 	/*

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-03  6:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-03  6:31 [PATCH] drivers/char/vt_ioctl.c: Fix VT_OPENQRY error value Graham Gower
2010-09-03  6:48 ` Graham Gower

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox