提交 a446b92e 编写于 作者: T Tian Tao 提交者: Pengyuan Zhao

vhost_vdpa: switch to vmemdup_user()

mainline inclusion
from mainline-v5.11-rc1
commit 0ab4b890
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WXCZ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ab4b8901a8edda4fd1c2aded36192566d89353f

----------------------------------------------------------------------

Replace opencoded alloc and copy with vmemdup_user()
Signed-off-by: NTian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1605057288-60400-1-git-send-email-tiantao6@hisilicon.comSigned-off-by: NMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: NPengyuan Zhao <zhaopengyuan@hisilicon.com>
上级 be1d2d41
...@@ -248,14 +248,10 @@ static long vhost_vdpa_set_config(struct vhost_vdpa *v, ...@@ -248,14 +248,10 @@ static long vhost_vdpa_set_config(struct vhost_vdpa *v,
return -EFAULT; return -EFAULT;
if (vhost_vdpa_config_validate(v, &config)) if (vhost_vdpa_config_validate(v, &config))
return -EINVAL; return -EINVAL;
buf = kvzalloc(config.len, GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, c->buf, config.len)) { buf = vmemdup_user(c->buf, config.len);
kvfree(buf); if (IS_ERR(buf))
return -EFAULT; return PTR_ERR(buf);
}
ops->set_config(vdpa, config.off, buf, config.len); ops->set_config(vdpa, config.off, buf, config.len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册