--- linux-2.6.18/fs/jffs2/nodelist.c.orig 2006-11-18 18:27:43.530579992 -0800 +++ linux-2.6.18/fs/jffs2/nodelist.c 2006-11-18 18:28:43.089525656 -0800 @@ -57,6 +57,16 @@ void jffs2_add_fd_to_list(struct jffs2_s void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint32_t size) { struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); +/* + DM: looks like it's legal for jffs2_lookup_node_frag to return + NULL but we were not checking for it (which leads to kernel oops and + our ultimate death when mounting jffs2 fs). +*/ + if( NULL == frag ) + { + dbg_fragtree("Hm, jffs2_lookup_node_frag returned NULL (empty fragtree)!\n"); + return; + } dbg_fragtree("truncating fragtree to 0x%08x bytes\n", size);