public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 4/7] JFFS2: Improve error checking
@ 2011-04-24  3:37 Baidu Liu
  2011-04-29 13:18 ` Detlev Zundel
  0 siblings, 1 reply; 4+ messages in thread
From: Baidu Liu @ 2011-04-24  3:37 UTC (permalink / raw)
  To: u-boot

 Check the return value when we do malloc.

Signed-off-by: Baidu Liu <liucai.lfn@gmail.com>
---
 fs/jffs2/jffs2_1pass.c      |   12 ++++++++++--
 fs/jffs2/jffs2_nand_1pass.c |    5 ++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index be6ac78..b3d94af 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -662,7 +662,8 @@ jffs2_free_cache(struct part_info *part)
 		pL = (struct b_lists *)part->jffs2_priv;
 		free_nodes(&pL->frag);
 		free_nodes(&pL->dir);
-		free(pL->readbuf);
+		if(pL->readbuf)
+			free(pL->readbuf);
 		free(pL);
 	}
 }
@@ -1470,9 +1471,16 @@ jffs2_1pass_build_lists(struct part_info * part)
 	/* lcd_off(); */
 
 	/* if we are building a list we need to refresh the cache. */
-	jffs_init_1pass_list(part);
+	if(! jffs_init_1pass_list(part))
+		return 0;
+	
 	pL = (struct b_lists *)part->jffs2_priv;
 	buf = malloc(buf_size);
+	if (!buf) {
+		printf("jffs2_1pass_build_lists: malloc failed\n");
+		return 0;
+	}
+	
 	puts ("Scanning JFFS2 FS:   ");
 
 	/* start at the beginning of the partition */
diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c
index 9bad690..885fa3c 100644
--- a/fs/jffs2/jffs2_nand_1pass.c
+++ b/fs/jffs2/jffs2_nand_1pass.c
@@ -251,6 +251,7 @@ jffs_init_1pass_list(struct part_info *part)
 		pL->dir.listCompare = compare_dirents;
 		pL->frag.listCompare = compare_inodes;
 #endif
+		return 1;
 	}
 	return 0;
 }
@@ -806,7 +807,9 @@ jffs2_1pass_build_lists(struct part_info * part)
 	nand = nand_info + id->num;
 
 	/* if we are building a list we need to refresh the cache. */
-	jffs_init_1pass_list(part);
+	if(! jffs_init_1pass_list(part))
+		return 0;
+	
 	pL = (struct b_lists *)part->jffs2_priv;
 	pL->partOffset = part->offset;
 	puts ("Scanning JFFS2 FS:   ");
-- 
1.7.3.1.msysgit.0

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

end of thread, other threads:[~2011-04-29 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24  3:37 [U-Boot] [PATCH 4/7] JFFS2: Improve error checking Baidu Liu
2011-04-29 13:18 ` Detlev Zundel
2011-04-29 15:02   ` Baidu Liu
2011-04-29 17:31     ` Detlev Zundel

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