diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 14:45:17 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:06 -0400 |
commit | 7b595756ec1f49e0049a9e01a1298d53a7faaa15 (patch) | |
tree | cd06687ab3e5c7a5a4ef91903dff207a18c4db76 /fs/sysfs/bin.c | |
parent | dbde0fcf9f8f6d477af3c32d9979e789ee680cde (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/bin.c')
-rw-r--r-- | fs/sysfs/bin.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 618b8aea6a7b..3c5574a40b09 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c | |||
@@ -175,25 +175,20 @@ static int open(struct inode * inode, struct file * file) | |||
175 | if (!sysfs_get_active(attr_sd)) | 175 | if (!sysfs_get_active(attr_sd)) |
176 | return -ENODEV; | 176 | return -ENODEV; |
177 | 177 | ||
178 | /* Grab the module reference for this attribute */ | ||
179 | error = -ENODEV; | ||
180 | if (!try_module_get(attr->attr.owner)) | ||
181 | goto err_sput; | ||
182 | |||
183 | error = -EACCES; | 178 | error = -EACCES; |
184 | if ((file->f_mode & FMODE_WRITE) && !(attr->write || attr->mmap)) | 179 | if ((file->f_mode & FMODE_WRITE) && !(attr->write || attr->mmap)) |
185 | goto err_mput; | 180 | goto err_out; |
186 | if ((file->f_mode & FMODE_READ) && !(attr->read || attr->mmap)) | 181 | if ((file->f_mode & FMODE_READ) && !(attr->read || attr->mmap)) |
187 | goto err_mput; | 182 | goto err_out; |
188 | 183 | ||
189 | error = -ENOMEM; | 184 | error = -ENOMEM; |
190 | bb = kzalloc(sizeof(*bb), GFP_KERNEL); | 185 | bb = kzalloc(sizeof(*bb), GFP_KERNEL); |
191 | if (!bb) | 186 | if (!bb) |
192 | goto err_mput; | 187 | goto err_out; |
193 | 188 | ||
194 | bb->buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); | 189 | bb->buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); |
195 | if (!bb->buffer) | 190 | if (!bb->buffer) |
196 | goto err_mput; | 191 | goto err_out; |
197 | 192 | ||
198 | mutex_init(&bb->mutex); | 193 | mutex_init(&bb->mutex); |
199 | file->private_data = bb; | 194 | file->private_data = bb; |
@@ -203,9 +198,7 @@ static int open(struct inode * inode, struct file * file) | |||
203 | sysfs_get(attr_sd); | 198 | sysfs_get(attr_sd); |
204 | return 0; | 199 | return 0; |
205 | 200 | ||
206 | err_mput: | 201 | err_out: |
207 | module_put(attr->attr.owner); | ||
208 | err_sput: | ||
209 | sysfs_put_active(attr_sd); | 202 | sysfs_put_active(attr_sd); |
210 | kfree(bb); | 203 | kfree(bb); |
211 | return error; | 204 | return error; |
@@ -214,13 +207,11 @@ static int open(struct inode * inode, struct file * file) | |||
214 | static int release(struct inode * inode, struct file * file) | 207 | static int release(struct inode * inode, struct file * file) |
215 | { | 208 | { |
216 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; | 209 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
217 | struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr; | ||
218 | struct bin_buffer *bb = file->private_data; | 210 | struct bin_buffer *bb = file->private_data; |
219 | 211 | ||
220 | if (bb->mmapped) | 212 | if (bb->mmapped) |
221 | sysfs_put_active_two(attr_sd); | 213 | sysfs_put_active_two(attr_sd); |
222 | sysfs_put(attr_sd); | 214 | sysfs_put(attr_sd); |
223 | module_put(attr->attr.owner); | ||
224 | kfree(bb->buffer); | 215 | kfree(bb->buffer); |
225 | kfree(bb); | 216 | kfree(bb); |
226 | return 0; | 217 | return 0; |