vt: use memdup_user in PIO_UNIMAP ioctl
authorAdam Borowski <kilobyte@angband.pl>
Sat, 3 Jun 2017 07:35:08 +0000 (09:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jun 2017 09:07:36 +0000 (11:07 +0200)
Again, a nice linear transfer that simplifies the code.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/consolemap.c

index c6a692f63a9b2f66a3380fd1766c73615bf5703b..a5f88cf0f61d56de1db09df0bd3e8a3eeec19789 100644 (file)
@@ -540,14 +540,9 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
        if (!ct)
                return 0;
 
-       unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL);
-       if (!unilist)
-               return -ENOMEM;
-
-       for (i = ct, plist = unilist; i; i--, plist++, list++) {
-               __get_user(plist->unicode, &list->unicode);
-               __get_user(plist->fontpos, &list->fontpos);
-       }
+       unilist = memdup_user(list, ct * sizeof(struct unipair));
+       if (IS_ERR(unilist))
+               return PTR_ERR(unilist);
 
        console_lock();