linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] UBIFS: fix memory leak on error path
@ 2012-05-17  9:03 Sidney Amani
  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:38 ` [PATCH] UBIFS: fix memory leak on error path Artem Bityutskiy
  0 siblings, 2 replies; 6+ messages in thread
From: Sidney Amani @ 2012-05-17  9:03 UTC (permalink / raw)
  To: linux-mtd; +Cc: Ben Gardiner, Sidney Amani

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-20  5:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-17  9:03 [PATCH] UBIFS: fix memory leak on error path Sidney Amani
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

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).