[JFFS2] Prevent oops after 'node added in wrong place' debug check
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Thu Jun 28 14:59:01 EDT 2007
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f79c44980aae3f50fe73e50789641df265953cc6
Commit: f79c44980aae3f50fe73e50789641df265953cc6
Parent: fab2c399129273713b7dcc6a54cef17ca124a47f
Author: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
AuthorDate: Sun Jun 24 19:22:29 2007 +0200
Committer: David Woodhouse <dwmw2 at infradead.org>
CommitDate: Thu Jun 28 18:55:27 2007 +0100
[JFFS2] Prevent oops after 'node added in wrong place' debug check
jffs2_add_physical_node_ref() should never really return error -- it's
an internal debugging check which triggered. We really need to work out
why and stop it happening. But in the meantime, let's make the failure
mode a little less nasty.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
fs/jffs2/write.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c
index c9fe0ab..1406f2c 100644
--- a/fs/jffs2/write.c
+++ b/fs/jffs2/write.c
@@ -173,6 +173,12 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
flash_ofs |= REF_NORMAL;
}
fn->raw = jffs2_add_physical_node_ref(c, flash_ofs, PAD(sizeof(*ri)+datalen), f->inocache);
+ if (IS_ERR(fn->raw)) {
+ void *hold_err = fn->raw;
+ /* Release the full_dnode which is now useless, and return */
+ jffs2_free_full_dnode(fn);
+ return ERR_PTR(PTR_ERR(hold_err));
+ }
fn->ofs = je32_to_cpu(ri->offset);
fn->size = je32_to_cpu(ri->dsize);
fn->frags = 0;
@@ -291,6 +297,12 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
}
/* Mark the space used */
fd->raw = jffs2_add_physical_node_ref(c, flash_ofs | REF_PRISTINE, PAD(sizeof(*rd)+namelen), f->inocache);
+ if (IS_ERR(fd->raw)) {
+ void *hold_err = fd->raw;
+ /* Release the full_dirent which is now useless, and return */
+ jffs2_free_full_dirent(fd);
+ return ERR_PTR(PTR_ERR(hold_err));
+ }
if (retried) {
jffs2_dbg_acct_sanity_check(c,NULL);
More information about the linux-mtd-cvs
mailing list