linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sidney Amani <seed95@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Ben Gardiner <bengardiner@nanometrics.ca>,
	Sidney Amani <seed95@gmail.com>
Subject: [PATCH] UBIFS: fix memory leak on error path
Date: Thu, 17 May 2012 19:03:32 +1000	[thread overview]
Message-ID: <1337245412-22222-1-git-send-email-seed95@gmail.com> (raw)

UBIFS leaks memory on error path in 'mount_ubifs()'. In case of failure in
'ubifs_lpt_init()' or 'ubifs_fixup_free_space()', it does not call
'ubifs_lpt_free()' whereas LPT data structures can potentially be allocated.
The amount of memory leaked can be quite high -- see 'ubifs_lpt_init()'.

The bug was introduced when moving the LPT initialisation earlier in the
mount process (commit '781c5717a95a74b294beb38b8276943b0f8b5bb4').

CC: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Sidney Amani <seed95@gmail.com>
---
 fs/ubifs/super.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 76e4e05..50216ec 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1296,12 +1296,12 @@ static int mount_ubifs(struct ubifs_info *c)
 
 	err = ubifs_lpt_init(c, 1, !c->ro_mount);
 	if (err)
-		goto out_master;
+		goto out_lpt;
 
 	if (!c->ro_mount && c->space_fixup) {
 		err = ubifs_fixup_free_space(c);
 		if (err)
-			goto out_master;
+			goto out_lpt;
 	}
 
 	if (!c->ro_mount) {
-- 
1.7.5.4

             reply	other threads:[~2012-05-17  9:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-17  9:03 Sidney Amani [this message]
2012-05-18 11:32 ` [PATCH 1/2] UBIFS: make ubifs_lpt_init clean-up in case of failure Artem Bityutskiy
2012-05-18 11:32   ` [PATCH 2/2] UBIFS: fix memory leak on error path Artem Bityutskiy
2012-05-20  5:49   ` [PATCH 1/2] UBIFS: make ubifs_lpt_init clean-up in case of failure Sidney Amani
2012-05-18 11:38 ` [PATCH] UBIFS: fix memory leak on error path Artem Bityutskiy
2012-05-20  5:49   ` Sidney Amani

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=1337245412-22222-1-git-send-email-seed95@gmail.com \
    --to=seed95@gmail.com \
    --cc=bengardiner@nanometrics.ca \
    --cc=linux-mtd@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).