Re: [PATCH 08/18] vfio/mdev: Reorganize mdev_device_create()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 23, 2021 at 08:20:40PM +0100, Christoph Hellwig wrote:
> >  	up_read(&parent->unreg_sem);
> > -	put_device(&mdev->dev);
> >  mdev_fail:
> >
> >
> >
> > -	mdev_put_parent(parent);
> > +	put_device(&mdev->dev);
> 
> That mdev_fail label is not very descriptive, what about free_device
> instead?

It is all a bit off normal, lets just fix it all in this patch too,
there is alot more changing in this function in later patches that
will all read better:

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index 517b6fd351b63a..f7559835b0610f 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -263,20 +263,20 @@ int mdev_device_create(struct mdev_type *type, const guid_t *uuid)
 	/* Check if parent unregistration has started */
 	if (!down_read_trylock(&parent->unreg_sem)) {
 		ret = -ENODEV;
-		goto mdev_fail;
+		goto out_put_device;
 	}
 
 	ret = parent->ops->create(&type->kobj, mdev);
 	if (ret)
-		goto ops_create_fail;
+		goto out_unlock;
 
 	ret = device_add(&mdev->dev);
 	if (ret)
-		goto add_fail;
+		goto out_remove;
 
 	ret = mdev_create_sysfs_files(mdev);
 	if (ret)
-		goto sysfs_fail;
+		goto out_del;
 
 	mdev->active = true;
 	dev_dbg(&mdev->dev, "MDEV: created\n");
@@ -284,13 +284,13 @@ int mdev_device_create(struct mdev_type *type, const guid_t *uuid)
 
 	return 0;
 
-sysfs_fail:
+out_del:
 	device_del(&mdev->dev);
-add_fail:
+out_remove:
 	parent->ops->remove(mdev);
-ops_create_fail:
+out_unlock:
 	up_read(&parent->unreg_sem);
-mdev_fail:
+out_put_device:
 	put_device(&mdev->dev);
 	return ret;
 }


Thanks,
Jason



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux