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

tty/vt: consolemap: check put_user() in con_get_unimap()

Only the return value of copy_to_user() is checked in con_get_unimap().
Do the same for put_user() of the count too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-16-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
949fafcd cb47d81f

+2 -1
+2 -1
drivers/tty/vt/consolemap.c
··· 813 813 console_unlock(); 814 814 if (copy_to_user(list, unilist, min(ect, ct) * sizeof(*unilist))) 815 815 ret = -EFAULT; 816 - put_user(ect, uct); 816 + if (put_user(ect, uct)) 817 + ret = -EFAULT; 817 818 kvfree(unilist); 818 819 return ret ? ret : (ect <= ct) ? 0 : -ENOMEM; 819 820 }