summaryrefslogtreecommitdiffstats
path: root/fs/configfs
diff options
context:
space:
mode:
authorChandra Seetharaman <sekharan@us.ibm.com>2006-10-10 15:15:55 -0700
committerMark Fasheh <mark.fasheh@oracle.com>2006-10-20 15:29:00 -0700
commit559c9ac391c046710bdeee5581dc5d9dda794881 (patch)
tree78cdf1ebc1027028b7e1e01d4ed34f2cf18742c9 /fs/configfs
parente2057c5a63821e17c8a54dab6db680c77ce7ee6c (diff)
downloadlinux-559c9ac391c046710bdeee5581dc5d9dda794881.tar.gz
linux-559c9ac391c046710bdeee5581dc5d9dda794881.tar.bz2
linux-559c9ac391c046710bdeee5581dc5d9dda794881.zip
configfs: handle kzalloc() failure in check_perm()
check_perm() does not drop the reference to the module when kzalloc() failure occurs. Signed-Off-By: Chandra Seetharaman <sekharan@us.ibm.com> Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/configfs')
-rw-r--r--fs/configfs/file.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index e6d5754a715e..cf33fac68c84 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -275,13 +275,14 @@ static int check_perm(struct inode * inode, struct file * file)
* it in file->private_data for easy access.
*/
buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
- if (buffer) {
- init_MUTEX(&buffer->sem);
- buffer->needs_read_fill = 1;
- buffer->ops = ops;
- file->private_data = buffer;
- } else
+ if (!buffer) {
error = -ENOMEM;
+ goto Enomem;
+ }
+ init_MUTEX(&buffer->sem);
+ buffer->needs_read_fill = 1;
+ buffer->ops = ops;
+ file->private_data = buffer;
goto Done;
Einval:
@@ -289,6 +290,7 @@ static int check_perm(struct inode * inode, struct file * file)
goto Done;
Eaccess:
error = -EACCES;
+ Enomem:
module_put(attr->ca_owner);
Done:
if (error && item)