Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'driver-core-3.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core fixes from Greg KH:
"Here are 3 patches for sysfs issues that have been reported. Well, 1
patch really, the first one is reverted as it's not really needed (the
correct fix is coming in through the different driver subsystems
instead)

But that 1 sysfs fix is needed, so this is still a good thing to pull
in now"

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

* tag 'driver-core-3.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
Revert "sysfs: handle duplicate removal attempts in sysfs_remove_group()"
sysfs: use a separate locking class for open files depending on mmap
sysfs: handle duplicate removal attempts in sysfs_remove_group()

+20 -2
+20 -2
fs/sysfs/file.c
··· 609 609 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 610 610 struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; 611 611 struct sysfs_open_file *of; 612 - bool has_read, has_write; 612 + bool has_read, has_write, has_mmap; 613 613 int error = -EACCES; 614 614 615 615 /* need attr_sd for attr and ops, its parent for kobj */ ··· 621 621 622 622 has_read = battr->read || battr->mmap; 623 623 has_write = battr->write || battr->mmap; 624 + has_mmap = battr->mmap; 624 625 } else { 625 626 const struct sysfs_ops *ops = sysfs_file_ops(attr_sd); 626 627 ··· 633 632 634 633 has_read = ops->show; 635 634 has_write = ops->store; 635 + has_mmap = false; 636 636 } 637 637 638 638 /* check perms and supported operations */ ··· 651 649 if (!of) 652 650 goto err_out; 653 651 654 - mutex_init(&of->mutex); 652 + /* 653 + * The following is done to give a different lockdep key to 654 + * @of->mutex for files which implement mmap. This is a rather 655 + * crude way to avoid false positive lockdep warning around 656 + * mm->mmap_sem - mmap nests @of->mutex under mm->mmap_sem and 657 + * reading /sys/block/sda/trace/act_mask grabs sr_mutex, under 658 + * which mm->mmap_sem nests, while holding @of->mutex. As each 659 + * open file has a separate mutex, it's okay as long as those don't 660 + * happen on the same file. At this point, we can't easily give 661 + * each file a separate locking class. Let's differentiate on 662 + * whether the file has mmap or not for now. 663 + */ 664 + if (has_mmap) 665 + mutex_init(&of->mutex); 666 + else 667 + mutex_init(&of->mutex); 668 + 655 669 of->sd = attr_sd; 656 670 of->file = file; 657 671