Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: vt, remove reduntant check

MAX_NR_CONSOLES and MAX_NR_USER_CONSOLES are both 63 since they were
introduced in 1.1.54. And since vc_allocate does:

if (currcons >= MAX_NR_CONSOLES)
return -ENXIO;

if (!vc_cons[currcons].d) {
if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE))
return -EPERM;
}

the second check is pointless. Remove both the check and the macro
MAX_NR_USER_CONSOLES.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
182846a0 b8995f52

-5
-4
drivers/tty/vt/vt.c
··· 768 768 struct vc_data *vc; 769 769 struct vt_notifier_param param; 770 770 771 - /* prevent users from taking too much memory */ 772 - if (currcons >= MAX_NR_USER_CONSOLES && !capable(CAP_SYS_RESOURCE)) 773 - return -EPERM; 774 - 775 771 /* due to the granularity of kmalloc, we waste some memory here */ 776 772 /* the alloc is done in two steps, to optimize the common situation 777 773 of a 25x80 console (structsize=216, screenbuf_size=4000) */
-1
include/uapi/linux/vt.h
··· 8 8 */ 9 9 #define MIN_NR_CONSOLES 1 /* must be at least 1 */ 10 10 #define MAX_NR_CONSOLES 63 /* serial lines start at 64 */ 11 - #define MAX_NR_USER_CONSOLES 63 /* must be root to allocate above this */ 12 11 /* Note: the ioctl VT_GETSTATE does not work for 13 12 consoles 16 and higher (since it returns a short) */ 14 13