Driver core: fix race in sysfs between sysfs_remove_file() and read()/write()
This patch prevents a race between IO and removing a file from sysfs. It introduces a list of sysfs_buffers associated with a file at the inode. Upon removal of a file the list is walked and the buffers marked orphaned. IO to orphaned buffers fails with -ENODEV. The driver can safely free associated data structures or be unloaded. Signed-off-by:Oliver Neukum <oliver@neukum.name> Acked-by:
Maneesh Soni <maneesh@in.ibm.com> Signed-off-by:
Greg Kroah-Hartman <gregkh@suse.de>
Showing
- fs/sysfs/bin.c 1 addition, 0 deletionsfs/sysfs/bin.c
- fs/sysfs/dir.c 1 addition, 0 deletionsfs/sysfs/dir.c
- fs/sysfs/file.c 50 additions, 17 deletionsfs/sysfs/file.c
- fs/sysfs/group.c 1 addition, 0 deletionsfs/sysfs/group.c
- fs/sysfs/inode.c 24 additions, 0 deletionsfs/sysfs/inode.c
- fs/sysfs/mount.c 9 additions, 0 deletionsfs/sysfs/mount.c
- fs/sysfs/symlink.c 1 addition, 0 deletionsfs/sysfs/symlink.c
- fs/sysfs/sysfs.h 16 additions, 0 deletionsfs/sysfs/sysfs.h
Loading
Please register or sign in to comment