summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2012-09-03 21:24:49 +0200
committerWolfgang Denk <wd@denx.de>2012-09-03 21:24:49 +0200
commit48efe65829102fe7936304c0ed96b3935800f40a (patch)
treeb758ca982d5300759ea951fd723ba43f66208d7f
parentf499131867de260c09ad0fafd7dbc3bb5fda3eb4 (diff)
parentbe73913b91ca1e86c7478c1ab8af7b7ba6f3e4ad (diff)
downloadu-boot-imx-48efe65829102fe7936304c0ed96b3935800f40a.zip
u-boot-imx-48efe65829102fe7936304c0ed96b3935800f40a.tar.gz
u-boot-imx-48efe65829102fe7936304c0ed96b3935800f40a.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-ubi
* 'master' of git://git.denx.de/u-boot-ubi: ubifs: Fix memory leak in ubifs_finddir Signed-off-by: Wolfgang Denk <wd@denx.de>
-rw-r--r--fs/ubifs/ubifs.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 604eb8f..c68802b 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -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)