* [PATCH] vhost_vdpa: switch to vmemdup_user()
@ 2020-11-11 1:14 Tian Tao
2020-11-11 10:50 ` Stefano Garzarella
0 siblings, 1 reply; 2+ messages in thread
From: Tian Tao @ 2020-11-11 1:14 UTC (permalink / raw)
To: mst, jasowang, kvm, virtualization, netdev, linux-kernel
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(-)
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vhost_vdpa: switch to vmemdup_user()
2020-11-11 1:14 [PATCH] vhost_vdpa: switch to vmemdup_user() Tian Tao
@ 2020-11-11 10:50 ` Stefano Garzarella
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Garzarella @ 2020-11-11 10:50 UTC (permalink / raw)
To: Tian Tao; +Cc: mst, jasowang, kvm, virtualization, netdev, linux-kernel
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-11 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-11 1:14 [PATCH] vhost_vdpa: switch to vmemdup_user() Tian Tao
2020-11-11 10:50 ` Stefano Garzarella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).