[PATCH 14/14] vfio/mdev: add mdev available instance checking to the core
Jason Gunthorpe
jgg at nvidia.com
Mon Jul 4 15:07:36 UTC 2022
On Mon, Jul 04, 2022 at 02:51:44PM +0200, Christoph Hellwig wrote:
> @@ -115,12 +116,15 @@ EXPORT_SYMBOL(mdev_unregister_parent);
> static void mdev_device_release(struct device *dev)
> {
> struct mdev_device *mdev = to_mdev_device(dev);
> + struct mdev_parent *parent = mdev->type->parent;
>
> /* Pairs with the get in mdev_device_create() */
> kobject_put(&mdev->type->kobj);
>
> mutex_lock(&mdev_list_lock);
> list_del(&mdev->next);
> + if (!parent->mdev_driver->get_available)
> + parent->available_instances++;
> mutex_unlock(&mdev_list_lock);
I think the kobject_put() needs to be after this reference to parent
because mdev_type_release() will:
put_device(type->parent->dev);
Which is potentially the last reference holding dev, and thus parent,
at this moment.
Jason
More information about the intel-gvt-dev
mailing list