summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-14 03:45:17 +0900
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 16:09:06 -0700
commit7b595756ec1f49e0049a9e01a1298d53a7faaa15 (patch)
treecd06687ab3e5c7a5a4ef91903dff207a18c4db76 /fs/sysfs/file.c
parentdbde0fcf9f8f6d477af3c32d9979e789ee680cde (diff)
sysfs: kill unnecessary attribute->owner
sysfs is now completely out of driver/module lifetime game. After deletion, a sysfs node doesn't access anything outside sysfs proper, so there's no reason to hold onto the attribute owners. Note that often the wrong modules were accounted for as owners leading to accessing removed modules. This patch kills now unnecessary attribute->owner. Note that with this change, userland holding a sysfs node does not prevent the backing module from being unloaded. For more info regarding lifetime rule cleanup, please read the following message. http://article.gmane.org/gmane.linux.kernel/510293 (tweaked by Greg to not delete the field just yet, to make it easier to merge things properly.) Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r--fs/sysfs/file.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index d673d9b5d33..a84b734f7b2 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -241,7 +241,6 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t
static int sysfs_open_file(struct inode *inode, struct file *file)
{
struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
- struct attribute *attr = attr_sd->s_elem.attr.attr;
struct kobject *kobj = attr_sd->s_parent->s_elem.dir.kobj;
struct sysfs_buffer * buffer;
struct sysfs_ops * ops = NULL;
@@ -251,11 +250,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
if (!sysfs_get_active_two(attr_sd))
return -ENODEV;
- /* Grab the module reference for this attribute */
- error = -ENODEV;
- if (!try_module_get(attr->owner))
- goto err_sput;
-
/* if the kobject has no ktype, then we assume that it is a subsystem
* itself, and use ops for it.
*/
@@ -272,7 +266,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
* or the subsystem have no operations.
*/
if (!ops)
- goto err_mput;
+ goto err_out;
/* File needs write support.
* The inode's perms must say it's ok,
@@ -280,7 +274,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
*/
if (file->f_mode & FMODE_WRITE) {
if (!(inode->i_mode & S_IWUGO) || !ops->store)
- goto err_mput;
+ goto err_out;
}
/* File needs read support.
@@ -289,7 +283,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
*/
if (file->f_mode & FMODE_READ) {
if (!(inode->i_mode & S_IRUGO) || !ops->show)
- goto err_mput;
+ goto err_out;
}
/* No error? Great, allocate a buffer for the file, and store it
@@ -298,7 +292,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
error = -ENOMEM;
buffer = kzalloc(sizeof(struct sysfs_buffer), GFP_KERNEL);
if (!buffer)
- goto err_mput;
+ goto err_out;
init_MUTEX(&buffer->sem);
buffer->needs_read_fill = 1;
@@ -310,9 +304,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
sysfs_get(attr_sd);
return 0;
- err_mput:
- module_put(attr->owner);
- err_sput:
+ err_out:
sysfs_put_active_two(attr_sd);
return error;
}
@@ -320,12 +312,9 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
static int sysfs_release(struct inode * inode, struct file * filp)
{
struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
- struct attribute *attr = attr_sd->s_elem.attr.attr;
struct sysfs_buffer *buffer = filp->private_data;
sysfs_put(attr_sd);
- /* After this point, attr should not be accessed. */
- module_put(attr->owner);
if (buffer) {
if (buffer->page)