* [U-Boot] [PATCH] ubifs: Fix memory leak in ubifs_finddir
@ 2012-08-28 12:00 Stefan Roese
2012-09-03 9:36 ` Stefan Roese
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Roese @ 2012-08-28 12:00 UTC (permalink / raw)
To: u-boot
This patch fixes a memory leak in ubifs_finddir().
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: dev.ma.dma at gmail.com
---
fs/ubifs/ubifs.c | 11 ++++++-----
1 file 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)
--
1.7.12
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] ubifs: Fix memory leak in ubifs_finddir
2012-08-28 12:00 [U-Boot] [PATCH] ubifs: Fix memory leak in ubifs_finddir Stefan Roese
@ 2012-09-03 9:36 ` Stefan Roese
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2012-09-03 9:36 UTC (permalink / raw)
To: u-boot
On 08/28/2012 02:00 PM, Stefan Roese wrote:
> This patch fixes a memory leak in ubifs_finddir().
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: dev.ma.dma at gmail.com
Applied to u-boot-ubi/master.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-03 9:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-28 12:00 [U-Boot] [PATCH] ubifs: Fix memory leak in ubifs_finddir Stefan Roese
2012-09-03 9:36 ` Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox