diff options
author | Wu Zongyong <wuzongyong@linux.alibaba.com> | 2021-10-29 17:14:46 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2021-11-01 04:30:35 -0400 |
commit | c53e5d1b5ea46cfd6acb4a51c324b2ec03e89e76 (patch) | |
tree | 0c2ee2550b602398e287ed46285a24067048a5cc /drivers/vdpa | |
parent | 3b970a5842c9114c82e60744c84a7d06ee51b6f9 (diff) | |
download | lwn-c53e5d1b5ea46cfd6acb4a51c324b2ec03e89e76.tar.gz lwn-c53e5d1b5ea46cfd6acb4a51c324b2ec03e89e76.zip |
vdpa: min vq num of vdpa device cannot be greater than max vq num
Just failed to probe the vdpa device if the min virtqueue num returned
by get_vq_num_min is greater than the max virtqueue num returned by
get_vq_num_max.
Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/21199b62cc10b2a9f2cf90eeb63ad080645d881f.1635493219.git.wuzongyong@linux.alibaba.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vdpa')
-rw-r--r-- | drivers/vdpa/vdpa.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 1dc121a07a93..d783a943647d 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -26,8 +26,16 @@ static int vdpa_dev_probe(struct device *d) { struct vdpa_device *vdev = dev_to_vdpa(d); struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver); + const struct vdpa_config_ops *ops = vdev->config; + u32 max_num, min_num = 1; int ret = 0; + max_num = ops->get_vq_num_max(vdev); + if (ops->get_vq_num_min) + min_num = ops->get_vq_num_min(vdev); + if (max_num < min_num) + return -EINVAL; + if (drv && drv->probe) ret = drv->probe(vdev); |