Re: [PATCH 33/34] vfio/mdev: Use the driver core to create the 'remove' file

From: Kirti Wankhede
Date: Tue Apr 12 2022 - 17:04:20 EST




On 4/11/2022 7:44 PM, Christoph Hellwig wrote:
From: Jason Gunthorpe <jgg@xxxxxxxxxx>

The device creator is supposed to use the dev.groups value to add sysfs
files before device_add is called, not call sysfs_create_files() after
device_add() returns. This creates a race with uevent delivery where the
extra attribute will not be visible.

This was being done because the groups had been co-opted by the mdev
driver, now that prior patches have moved the driver's groups to the
struct device_driver the dev.group is properly free for use here.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
drivers/vfio/mdev/mdev_core.c | 1 +
drivers/vfio/mdev/mdev_private.h | 2 ++
drivers/vfio/mdev/mdev_sysfs.c | 19 ++++++++++---------
3 files changed, 13 insertions(+), 9 deletions(-)


Reviewed-by: Kirti Wankhede <kwankhede@xxxxxxxxxx>