Skip to content

Commit 60d69cb

Browse files
torvaldsgregkh
authored andcommitted
vt_kdsetmode: extend console locking
commit 2287a51 upstream. As per the long-suffering comment. Reported-by: Minh Yuan <yuanmingbuaa@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0a178a0 commit 60d69cb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/tty/vt/vt_ioctl.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ int vt_waitactive(int n)
246246
*
247247
* XXX It should at least call into the driver, fbdev's definitely need to
248248
* restore their engine state. --BenH
249+
*
250+
* Called with the console lock held.
249251
*/
250252
static int vt_kdsetmode(struct vc_data *vc, unsigned long mode)
251253
{
@@ -262,7 +264,6 @@ static int vt_kdsetmode(struct vc_data *vc, unsigned long mode)
262264
return -EINVAL;
263265
}
264266

265-
/* FIXME: this needs the console lock extending */
266267
if (vc->vc_mode == mode)
267268
return 0;
268269

@@ -271,12 +272,10 @@ static int vt_kdsetmode(struct vc_data *vc, unsigned long mode)
271272
return 0;
272273

273274
/* explicitly blank/unblank the screen if switching modes */
274-
console_lock();
275275
if (mode == KD_TEXT)
276276
do_unblank_screen(1);
277277
else
278278
do_blank_screen(1);
279-
console_unlock();
280279

281280
return 0;
282281
}
@@ -378,7 +377,10 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd,
378377
if (!perm)
379378
return -EPERM;
380379

381-
return vt_kdsetmode(vc, arg);
380+
console_lock();
381+
ret = vt_kdsetmode(vc, arg);
382+
console_unlock();
383+
return ret;
382384

383385
case KDGETMODE:
384386
return put_user(vc->vc_mode, (int __user *)arg);

0 commit comments

Comments
 (0)