Skip to content

Commit

Permalink
vfio/mdev: Re-order sysfs attribute creation
Browse files Browse the repository at this point in the history
There exists a gap at the end of mdev_device_create() where the device
is visible to userspace, but we're not yet ready to handle removal, as
triggered through the 'remove' attribute.  We handle this properly in
mdev_device_remove() with an -EAGAIN return, but we can marginally
reduce this gap by adding this attribute as a final step of our sysfs
setup.

Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
awilliam committed Jun 8, 2018
1 parent 002fe99 commit 6a62c1d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/vfio/mdev/mdev_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,24 @@ int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type)
{
int ret;

ret = sysfs_create_files(&dev->kobj, mdev_device_attrs);
if (ret)
return ret;

ret = sysfs_create_link(type->devices_kobj, &dev->kobj, dev_name(dev));
if (ret)
goto device_link_failed;
return ret;

ret = sysfs_create_link(&dev->kobj, &type->kobj, "mdev_type");
if (ret)
goto type_link_failed;

ret = sysfs_create_files(&dev->kobj, mdev_device_attrs);
if (ret)
goto create_files_failed;

return ret;

create_files_failed:
sysfs_remove_link(&dev->kobj, "mdev_type");
type_link_failed:
sysfs_remove_link(type->devices_kobj, dev_name(dev));
device_link_failed:
sysfs_remove_files(&dev->kobj, mdev_device_attrs);
return ret;
}

Expand Down

0 comments on commit 6a62c1d

Please sign in to comment.