public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] jffs2: potential memory leaks in jffs2_scan_medium()
@ 2006-06-23  3:43 Florin Malita
  0 siblings, 0 replies; only message in thread
From: Florin Malita @ 2006-06-23  3:43 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-kernel

This patch deals with 3 return paths that fail to perform proper cleanup
(which can result into leaking 'flashbuf' and/or 's').

Coverity IDs: 676, 1301

Signed-off-by: Florin Malita <fmalita@gmail.com>
---

 fs/jffs2/scan.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 6161808..4a068de 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -128,12 +128,12 @@ #endif
 	}
 
 	if (jffs2_sum_active()) {
-		s = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
+		s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
 		if (!s) {
 			JFFS2_WARNING("Can't allocate memory for summary\n");
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto out;
 		}
-		memset(s, 0, sizeof(struct jffs2_summary));
 	}
 
 	for (i=0; i<c->nr_blocks; i++) {
@@ -194,7 +194,7 @@ #endif
 				if (c->nextblock) {
 					ret = file_dirty(c, c->nextblock);
 					if (ret)
-						return ret;
+						goto out;
 					/* deleting summary information of the old nextblock */
 					jffs2_sum_reset_collected(c->summary);
 				}
@@ -205,7 +205,7 @@ #endif
 			} else {
 				ret = file_dirty(c, jeb);
 				if (ret)
-					return ret;
+					goto out;
 			}
 			break;
 



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-23  3:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-23  3:43 [PATCH] jffs2: potential memory leaks in jffs2_scan_medium() Florin Malita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox