]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ubifs: Fix memory leak in ubifs_finddir
authorStefan Roese <sr@denx.de>
Tue, 28 Aug 2012 12:00:24 +0000 (14:00 +0200)
committerStefan Roese <sr@denx.de>
Mon, 3 Sep 2012 09:37:50 +0000 (11:37 +0200)
This patch fixes a memory leak in ubifs_finddir().

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: dev.ma.dma@gmail.com
fs/ubifs/ubifs.c

index 604eb8fdc213ecf1482222597ebf0663c0776bf7..c68802bc8d1c480d71faca9cd04f601786f7e19c 100644 (file)
@@ -295,6 +295,7 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
        struct file *file;
        struct dentry *dentry;
        struct inode *dir;
+       int ret = 0;
 
        file = kzalloc(sizeof(struct file), 0);
        dentry = kzalloc(sizeof(struct dentry), 0);
@@ -336,7 +337,8 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
                if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) &&
                    (strlen(dirname) == nm.len)) {
                        *inum = le64_to_cpu(dent->inum);
-                       return 1;
+                       ret = 1;
+                       goto out_free;
                }
 
                /* Switch to the next entry */
@@ -355,11 +357,10 @@ static int ubifs_finddir(struct super_block *sb, char *dirname,
        }
 
 out:
-       if (err != -ENOENT) {
+       if (err != -ENOENT)
                ubifs_err("cannot find next direntry, error %d", err);
-               return err;
-       }
 
+out_free:
        if (file->private_data)
                kfree(file->private_data);
        if (file)
@@ -369,7 +370,7 @@ out:
        if (dir)
                free(dir);
 
-       return 0;
+       return ret;
 }
 
 static unsigned long ubifs_findfile(struct super_block *sb, char *filename)