Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4968636 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'driver-core-3.13-rc2' of...

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: default avatarGreg 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()
parents ba33fef0 81440e73
Loading
Loading
Loading
Loading
+20 −2
Original line number Original line Diff line number Diff line
@@ -609,7 +609,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
	struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
	struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
	struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
	struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
	struct sysfs_open_file *of;
	struct sysfs_open_file *of;
	bool has_read, has_write;
	bool has_read, has_write, has_mmap;
	int error = -EACCES;
	int error = -EACCES;


	/* need attr_sd for attr and ops, its parent for kobj */
	/* need attr_sd for attr and ops, its parent for kobj */
@@ -621,6 +621,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)


		has_read = battr->read || battr->mmap;
		has_read = battr->read || battr->mmap;
		has_write = battr->write || battr->mmap;
		has_write = battr->write || battr->mmap;
		has_mmap = battr->mmap;
	} else {
	} else {
		const struct sysfs_ops *ops = sysfs_file_ops(attr_sd);
		const struct sysfs_ops *ops = sysfs_file_ops(attr_sd);


@@ -632,6 +633,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)


		has_read = ops->show;
		has_read = ops->show;
		has_write = ops->store;
		has_write = ops->store;
		has_mmap = false;
	}
	}


	/* check perms and supported operations */
	/* check perms and supported operations */
@@ -649,7 +651,23 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
	if (!of)
	if (!of)
		goto err_out;
		goto err_out;


	/*
	 * The following is done to give a different lockdep key to
	 * @of->mutex for files which implement mmap.  This is a rather
	 * crude way to avoid false positive lockdep warning around
	 * mm->mmap_sem - mmap nests @of->mutex under mm->mmap_sem and
	 * reading /sys/block/sda/trace/act_mask grabs sr_mutex, under
	 * which mm->mmap_sem nests, while holding @of->mutex.  As each
	 * open file has a separate mutex, it's okay as long as those don't
	 * happen on the same file.  At this point, we can't easily give
	 * each file a separate locking class.  Let's differentiate on
	 * whether the file has mmap or not for now.
	 */
	if (has_mmap)
		mutex_init(&of->mutex);
		mutex_init(&of->mutex);
	else
		mutex_init(&of->mutex);

	of->sd = attr_sd;
	of->sd = attr_sd;
	of->file = file;
	of->file = file;