提交 44570726 编写于 作者: S Stefano Garzarella 提交者: Pengyuan Zhao

vhost/vdpa: use get_config_size callback in vhost_vdpa_config_validate()

stable inclusion
from stable-v5.13
commit d6d8bb92
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WXCZ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d6d8bb92fdde6390037bf9da174ed3ab551c04d7
----------------------------------------------------------------------

Let's use the new 'get_config_size()' callback available instead of
using the 'virtio_id' to get the size of the device config space.
Signed-off-by: NStefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-10-sgarzare@redhat.comSigned-off-by: NMichael S. Tsirkin <mst@redhat.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NPengyuan Zhao <zhaopengyuan@hisilicon.com>
上级 36b64ccd
...@@ -191,13 +191,8 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp) ...@@ -191,13 +191,8 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
static int vhost_vdpa_config_validate(struct vhost_vdpa *v, static int vhost_vdpa_config_validate(struct vhost_vdpa *v,
struct vhost_vdpa_config *c) struct vhost_vdpa_config *c)
{ {
long size = 0; struct vdpa_device *vdpa = v->vdpa;
long size = vdpa->config->get_config_size(vdpa);
switch (v->virtio_id) {
case VIRTIO_ID_NET:
size = sizeof(struct virtio_net_config);
break;
}
if (c->len == 0 || c->off > size) if (c->len == 0 || c->off > size)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册