mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Muhammad Falak R Wani <falakreyaz@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Pavel Machek <pavel@ucw.cz>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty/vt/keyboard: use memdup_user().
Date: Fri, 20 May 2016 14:27:05 +0200	[thread overview]
Message-ID: <20160520122705.GW10620@var.bordeaux.inria.fr> (raw)
In-Reply-To: <1463747026-23968-1-git-send-email-falakreyaz@gmail.com>

Muhammad Falak R Wani, on Fri 20 May 2016 17:53:28 +0530, wrote:
> Use memdup_user to duplicate a memory region from user-space to
> kernel-space, instead of open coding using kmalloc & copy_from_user.
> 
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  drivers/tty/vt/keyboard.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> index f973bfc..698ea43 100644
> --- a/drivers/tty/vt/keyboard.c
> +++ b/drivers/tty/vt/keyboard.c
> @@ -1745,16 +1745,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
>  			return -EINVAL;
>  
>  		if (ct) {
> -			buf = kmalloc(ct * sizeof(struct kbdiacruc),
> -								GFP_KERNEL);
> -			if (buf == NULL)
> -				return -ENOMEM;
> -
> -			if (copy_from_user(buf, a->kbdiacruc,
> -					ct * sizeof(struct kbdiacruc))) {
> -				kfree(buf);
> -				return -EFAULT;
> -			}
> +			buf = memdup_user(a->kbdiacruc,
> +					  ct * sizeof(struct kbdiacruc));
> +			if (IS_ERR(buf))
> +				return PTR_ERR(buf);
>  		} 
>  		spin_lock_irqsave(&kbd_event_lock, flags);
>  		if (ct)
> -- 
> 1.9.1
> 

-- 
Samuel
(03:13:14) <j> bon
(03:13:19) <j> il est tard :p
(03:13:25) <g> c'est l'heure de manger
(03:13:38) <j> hm j'ai mangé à 1h moi, j'ai des horaires raisonnables

  reply	other threads:[~2016-05-20 12:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 12:23 Muhammad Falak R Wani
2016-05-20 12:27 ` Samuel Thibault [this message]
2016-07-21  0:54   ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160520122705.GW10620@var.bordeaux.inria.fr \
    --to=samuel.thibault@ens-lyon.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=falakreyaz@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®