From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751285AbdFCHfy (ORCPT ); Sat, 3 Jun 2017 03:35:54 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:58435 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192AbdFCHfW (ORCPT ); Sat, 3 Jun 2017 03:35:22 -0400 From: Adam Borowski To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org Cc: Adam Borowski Date: Sat, 3 Jun 2017 09:35:08 +0200 Message-Id: <20170603073509.4718-4-kilobyte@angband.pl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170603073509.4718-1-kilobyte@angband.pl> References: <20170603073255.zgpfmdp2pqusz4qw@angband.pl> <20170603073509.4718-1-kilobyte@angband.pl> X-SA-Exim-Connect-IP: 89.71.161.30 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH 4/5] vt: use memdup_user in PIO_UNIMAP ioctl X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Again, a nice linear transfer that simplifies the code. Signed-off-by: Adam Borowski --- drivers/tty/vt/consolemap.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index c6a692f63a9b..a5f88cf0f61d 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -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(); -- 2.11.0