提交 29dd64a1 编写于 作者: W Wu Zongyong 提交者: Pengyuan Zhao

vdpa: min vq num of vdpa device cannot be greater than max vq num

mainline inclusion
from mainline-v5.16-rc1
commit c53e5d1b
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=c53e5d1b5ea46cfd6acb4a51c324b2ec03e89e76

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

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: NWu Zongyong <wuzongyong@linux.alibaba.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/21199b62cc10b2a9f2cf90eeb63ad080645d881f.1635493219.git.wuzongyong@linux.alibaba.comSigned-off-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NPengyuan Zhao <zhaopengyuan@hisilicon.com>
上级 3ecde7ab
...@@ -26,8 +26,16 @@ static int vdpa_dev_probe(struct device *d) ...@@ -26,8 +26,16 @@ static int vdpa_dev_probe(struct device *d)
{ {
struct vdpa_device *vdev = dev_to_vdpa(d); struct vdpa_device *vdev = dev_to_vdpa(d);
struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver); 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; 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) if (drv && drv->probe)
ret = drv->probe(vdev); ret = drv->probe(vdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册