提交 0ee1a8ef 编写于 作者: P Parav Pandit 提交者: Xie XiuQi

vfio/mdev: Avoid release parent reference during error path

mainline inclusion
from mainline-5.2-rc1
commit 60e7f2c3
category: bugfix
bugzilla: 15889
CVE: NA

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

During mdev parent registration in mdev_register_device(),
if parent device is duplicate, it releases the reference of existing
parent device.
This is incorrect. Existing parent device should not be touched.

Fixes: 7b96953b ("vfio: Mediated device Core driver")
Reviewed-by: NCornelia Huck <cohuck@redhat.com>
Reviewed-by: NKirti Wankhede <kwankhede@nvidia.com>
Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: NParav Pandit <parav@mellanox.com>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NXuefeng Wang <wxf.wang@hisilicon.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f187a1b9
...@@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) ...@@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
/* Check for duplicate */ /* Check for duplicate */
parent = __find_parent_device(dev); parent = __find_parent_device(dev);
if (parent) { if (parent) {
parent = NULL;
ret = -EEXIST; ret = -EEXIST;
goto add_dev_err; goto add_dev_err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册