diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 29cced1cd27784a708df783b2f81e2340c86f145..e3c4f059b21a202b36e8a18930432b546bac9bc2 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -197,7 +197,7 @@ static int vhost_vdpa_config_validate(struct vhost_vdpa *v, struct vdpa_device *vdpa = v->vdpa; long size = vdpa->config->get_config_size(vdpa); - if (c->len == 0) + if (c->len == 0 || c->off > size) return -EINVAL; if (c->len > size - c->off)