tty/vt: consolemap: check put_user() in con_get_unimap()
authorJiri Slaby <jslaby@suse.cz>
Tue, 7 Jun 2022 10:49:26 +0000 (12:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jun 2022 11:37:02 +0000 (13:37 +0200)
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>
drivers/tty/vt/consolemap.c

index 831450f2bfd1dd2e7fbfb509959c7b6d59cf3a98..92b5dddb00d983ff56782591f6189e3cd092fe34 100644 (file)
@@ -813,7 +813,8 @@ unlock:
        console_unlock();
        if (copy_to_user(list, unilist, min(ect, ct) * sizeof(*unilist)))
                ret = -EFAULT;
-       put_user(ect, uct);
+       if (put_user(ect, uct))
+               ret = -EFAULT;
        kvfree(unilist);
        return ret ? ret : (ect <= ct) ? 0 : -ENOMEM;
 }