]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
vfio/mdev: Avoid release parent reference during error path
authorParav Pandit <parav@mellanox.com>
Tue, 30 Apr 2019 22:49:28 +0000 (17:49 -0500)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 7 May 2019 17:23:13 +0000 (11:23 -0600)
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>
drivers/vfio/mdev/mdev_core.c

index b96fedc77ee51219a9c4f71800e43dc529114156..1299d2e72ce2ef3ab773198fc985b3b367910982 100644 (file)
@@ -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;
        }