mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Cc: dev.ma.dma@gmail.com, Stefan Roese <sr@denx.de>
Subject: [PATCH 18/18] ubifs: Fix memory leak in ubifs_finddir
Date: Mon,  3 Dec 2012 18:08:34 +0000	[thread overview]
Message-ID: <1354558114-28799-19-git-send-email-renaud.barbier@ge.com> (raw)
In-Reply-To: <1354558114-28799-1-git-send-email-renaud.barbier@ge.com>

From: Stefan Roese <sr@denx.de>

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 |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index bd9ac84..a3ac674 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -324,6 +324,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);
@@ -365,7 +366,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 */
@@ -384,11 +386,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)
@@ -398,7 +399,7 @@ out:
 	if (dir)
 		free(dir);
 
-	return 0;
+	return ret;
 }
 
 static unsigned long ubifs_findfile(struct super_block *sb,
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-12-03 18:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 18:08 [PATCH 00/18] UBIFS support Renaud Barbier
2012-12-03 18:08 ` [PATCH 01/18] fs/fs.c: check that fsdev->cdev->dev is not NULL Renaud Barbier
2012-12-03 18:08 ` [PATCH 02/18] UBIFS: preparation Renaud Barbier
2012-12-03 18:08 ` [PATCH 03/18] UBIFS: header files (1/2) Renaud Barbier
2012-12-03 18:08 ` [PATCH 04/18] UBIFS: header files (2/2) Renaud Barbier
2012-12-03 18:08 ` [PATCH 05/18] UBIFS: file operations Renaud Barbier
2012-12-04 22:53   ` Sascha Hauer
2012-12-03 18:08 ` [PATCH 06/18] UBIFS: initialization Renaud Barbier
2012-12-03 18:08 ` [PATCH 07/18] UBIFS: journal Renaud Barbier
2012-12-03 18:08 ` [PATCH 08/18] UBIFS: I/O subsystem Renaud Barbier
2012-12-03 18:08 ` [PATCH 09/18] UBIFS: LEB support Renaud Barbier
2012-12-03 18:08 ` [PATCH 10/18] UBIFS: master node Renaud Barbier
2012-12-03 18:08 ` [PATCH 11/18] UBIFS: recovery Renaud Barbier
2012-12-03 18:08 ` [PATCH 12/18] UBIFS: tree node cache Renaud Barbier
2012-12-03 18:08 ` [PATCH 13/18] UBIFS: superblock Renaud Barbier
2012-12-03 18:08 ` [PATCH 14/18] UBIFS: scan Renaud Barbier
2012-12-03 18:08 ` [PATCH 15/18] UBIFS: configuration and build directives Renaud Barbier
2012-12-03 18:08 ` [PATCH 16/18] ubifs bad superblock bug Renaud Barbier
2012-12-03 18:08 ` [PATCH 17/18] UBIFS: Improve error message when reading superblock failed Renaud Barbier
2012-12-03 18:08 ` Renaud Barbier [this message]
2012-12-03 19:17 ` [PATCH 00/18] UBIFS support Robert Jarzmik
2012-12-04 10:35   ` Renaud Barbier
2012-12-04 20:09     ` Robert Jarzmik
2012-12-05 11:47       ` Renaud Barbier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1354558114-28799-19-git-send-email-renaud.barbier@ge.com \
    --to=renaud.barbier@ge.com \
    --cc=barebox@lists.infradead.org \
    --cc=dev.ma.dma@gmail.com \
    --cc=sr@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox