diff options
author | Parav Pandit <parav@mellanox.com> | 2019-05-01 00:49:28 +0200 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2019-05-07 19:23:13 +0200 |
commit | 60e7f2c3fe9919cee9534b422865eed49f4efb15 (patch) | |
tree | a254a69e9d27acf938c3a85755a8a7927a9c87bb /drivers/vfio | |
parent | vfio-pci/nvlink2: Fix potential VMA leak (diff) | |
download | linux-60e7f2c3fe9919cee9534b422865eed49f4efb15.tar.xz linux-60e7f2c3fe9919cee9534b422865eed49f4efb15.zip |
vfio/mdev: Avoid release parent reference during error path
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 <cohuck@redhat.com>
Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/mdev/mdev_core.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index b96fedc77ee5..1299d2e72ce2 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -181,6 +181,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; } |