From 0ee1a8ef995594e463d81cb1d5293c47f66dfeb9 Mon Sep 17 00:00:00 2001 From: Parav Pandit Date: Fri, 24 May 2019 10:59:43 +0800 Subject: [PATCH] vfio/mdev: Avoid release parent reference during error path mainline inclusion from mainline-5.2-rc1 commit 60e7f2c3fe99 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: 7b96953bc640 ("vfio: Mediated device Core driver") Reviewed-by: Cornelia Huck Reviewed-by: Kirti Wankhede Reviewed-by: Maxim Levitsky Signed-off-by: Parav Pandit Signed-off-by: Alex Williamson Signed-off-by: Yang Yingliang Reviewed-by: Xuefeng Wang Signed-off-by: Yang Yingliang --- drivers/vfio/mdev/mdev_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index 1506647573c0..e052f62fdea7 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) /* Check for duplicate */ parent = __find_parent_device(dev); if (parent) { + parent = NULL; ret = -EEXIST; goto add_dev_err; } -- GitLab