public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: "Geliang Tang" <geliangtang@gmail.com>,
	"Felipe Balbi" <balbi@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Vincent Pelletier" <plr.vincent@gmail.com>,
	"Felix Hädicke" <felixhaedicke@web.de>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"Jim Lin" <jilin@nvidia.com>
Cc: Geliang Tang <geliangtang@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_fs: use memdup_user
Date: Sun, 14 May 2017 13:33:29 +0200	[thread overview]
Message-ID: <xa1to9uvvfjq.fsf@mina86.com> (raw)
In-Reply-To: <694b8a4beb2ec1e087321bc423e5cd0c69e5a717.1494576863.git.geliangtang@gmail.com>

On Sat, May 13 2017, Geliang Tang wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  drivers/usb/gadget/function/f_fs.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 71dd27c..5754538 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -3692,14 +3692,9 @@ static char *ffs_prepare_buffer(const char __user *buf, size_t len)
>  	if (unlikely(!len))
>  		return NULL;
>  
> -	data = kmalloc(len, GFP_KERNEL);
> -	if (unlikely(!data))
> -		return ERR_PTR(-ENOMEM);
> -
> -	if (unlikely(copy_from_user(data, buf, len))) {
> -		kfree(data);
> -		return ERR_PTR(-EFAULT);
> -	}
> +	data = memdup_user(buf, len);
> +	if (unlikely(IS_ERR(data)))
> +		return data;
>  
>  	pr_vdebug("Buffer from user space:\n");
>  	ffs_dump_mem("", data, len);

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»

  parent reply	other threads:[~2017-05-14 11:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-13  3:15 [PATCH] KEYS: use memdup_user Geliang Tang
2017-05-13  3:15 ` [PATCH] mmc: block: " Geliang Tang
2017-05-19  7:43   ` Ulf Hansson
2017-05-13  3:15 ` [PATCH] usb: gadget: f_fs: " Geliang Tang
2017-05-13  8:05   ` Dan Carpenter
2017-05-21  3:25     ` Al Viro
2017-05-14 11:33   ` Michal Nazarewicz [this message]
2017-05-13  3:16 ` [PATCH] USB: iowarrior: " Geliang Tang
2017-05-15 10:14   ` Johan Hovold

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=xa1to9uvvfjq.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=balbi@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=felixhaedicke@web.de \
    --cc=geliangtang@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jilin@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=plr.vincent@gmail.com \
    /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