]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
configfs: handle kzalloc() failure in check_perm()
authorChandra Seetharaman <sekharan@us.ibm.com>
Tue, 10 Oct 2006 22:15:55 +0000 (15:15 -0700)
committerMark Fasheh <mark.fasheh@oracle.com>
Fri, 20 Oct 2006 22:29:00 +0000 (15:29 -0700)
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>
fs/configfs/file.c

index e6d5754a715ecde980dd50225495d3628c49e2d8..cf33fac68c840cccc21ac91c617064ac36f90097 100644 (file)
@@ -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)