History

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.

Wu Zongyong committed 5 years ago

Commit c53e5d11 parent 3b970a51 file · +8 −0Browse files

Unified · Split

drivers/vdpa/vdpa.c+8−0
@@ -26,8 +26,16 @@ static int vdpa_dev_probe(struct device *d) · 25 unmodified lines
2626 {
2727 struct vdpa_device *vdev = dev_to_vdpa(d);
2828 struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver);
29+ const struct vdpa_config_ops *ops = vdev->config;
30+ u32 max_num, min_num = 1;
2931 int ret = 0;
3032
33+ max_num = ops->get_vq_num_max(vdev);
34+ if (ops->get_vq_num_min)
35+ min_num = ops->get_vq_num_min(vdev);
36+ if (max_num < min_num)
37+ return -EINVAL;
38+
3139 if (drv && drv->probe)
3240 ret = drv->probe(vdev);
3341