From: Stefano Garzarella <sgarzare@redhat.com>
To: Tian Tao <tiantao6@hisilicon.com>
Cc: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost_vdpa: switch to vmemdup_user()
Date: Wed, 11 Nov 2020 11:50:31 +0100 [thread overview]
Message-ID: <20201111105031.mtdbvt7grkxeuwn4@steredhat> (raw)
In-Reply-To: <1605057288-60400-1-git-send-email-tiantao6@hisilicon.com>
On Wed, Nov 11, 2020 at 09:14:48AM +0800, Tian Tao wrote:
>Replace opencoded alloc and copy with vmemdup_user()
>
>Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
>---
> drivers/vhost/vdpa.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
>index 2754f30..4c39583 100644
>--- a/drivers/vhost/vdpa.c
>+++ b/drivers/vhost/vdpa.c
>@@ -245,14 +245,10 @@ static long vhost_vdpa_set_config(struct vhost_vdpa *v,
> return -EFAULT;
> if (vhost_vdpa_config_validate(v, &config))
> return -EINVAL;
>- buf = kvzalloc(config.len, GFP_KERNEL);
>- if (!buf)
>- return -ENOMEM;
>
>- if (copy_from_user(buf, c->buf, config.len)) {
>- kvfree(buf);
>- return -EFAULT;
>- }
>+ buf = vmemdup_user(c->buf, config.len);
>+ if (IS_ERR(buf))
>+ return PTR_ERR(buf);
>
> ops->set_config(vdpa, config.off, buf, config.len);
>
>--
>2.7.4
>
prev parent reply other threads:[~2020-11-11 10:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 1:14 [PATCH] vhost_vdpa: switch to vmemdup_user() Tian Tao
2020-11-11 10:50 ` Stefano Garzarella [this message]
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=20201111105031.mtdbvt7grkxeuwn4@steredhat \
--to=sgarzare@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=tiantao6@hisilicon.com \
--cc=virtualization@lists.linux-foundation.org \
/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