Commit f2bdd885 authored by David Woodhouse's avatar David Woodhouse

Fix jffs2 memory leak on mount error

parent 4a98f95f
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: scan.c,v 1.103 2003/10/07 14:46:23 dwmw2 Exp $ * $Id: scan.c,v 1.104 2003/10/11 14:52:48 dwmw2 Exp $
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -116,7 +116,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -116,7 +116,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), buf_size); ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), buf_size);
if (ret < 0) if (ret < 0)
return ret; goto out;
ACCT_PARANOIA_CHECK(jeb); ACCT_PARANOIA_CHECK(jeb);
...@@ -240,17 +240,20 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -240,17 +240,20 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
if ( !c->used_size && ((empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { if ( !c->used_size && ((empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");
printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks);
return -EIO; ret = -EIO;
goto out;
} }
jffs2_erase_pending_trigger(c); jffs2_erase_pending_trigger(c);
} }
ret = 0;
out:
if (buf_size) if (buf_size)
kfree(flashbuf); kfree(flashbuf);
#ifndef __ECOS #ifndef __ECOS
else else
c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size); c->mtd->unpoint(c->mtd, flashbuf, 0, c->mtd->size);
#endif #endif
return 0; return ret;
} }
static int jffs2_fill_scan_buf (struct jffs2_sb_info *c, unsigned char *buf, static int jffs2_fill_scan_buf (struct jffs2_sb_info *c, unsigned char *buf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment