diff options
Diffstat (limited to 'fs/jffs2/readinode.c')
-rw-r--r-- | fs/jffs2/readinode.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 4884d5edfe65..12e83f67eee4 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -229,9 +229,16 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c, | |||
229 | check anyway. */ | 229 | check anyway. */ |
230 | if (!tn->fn->size) { | 230 | if (!tn->fn->size) { |
231 | if (rii->mdata_tn) { | 231 | if (rii->mdata_tn) { |
232 | /* We had a candidate mdata node already */ | 232 | if (rii->mdata_tn->version < tn->version) { |
233 | dbg_readinode("kill old mdata with ver %d\n", rii->mdata_tn->version); | 233 | /* We had a candidate mdata node already */ |
234 | jffs2_kill_tn(c, rii->mdata_tn); | 234 | dbg_readinode("kill old mdata with ver %d\n", rii->mdata_tn->version); |
235 | jffs2_kill_tn(c, rii->mdata_tn); | ||
236 | } else { | ||
237 | dbg_readinode("kill new mdata with ver %d (older than existing %d\n", | ||
238 | tn->version, rii->mdata_tn->version); | ||
239 | jffs2_kill_tn(c, tn); | ||
240 | return 0; | ||
241 | } | ||
235 | } | 242 | } |
236 | rii->mdata_tn = tn; | 243 | rii->mdata_tn = tn; |
237 | dbg_readinode("keep new mdata with ver %d\n", tn->version); | 244 | dbg_readinode("keep new mdata with ver %d\n", tn->version); |
@@ -1044,7 +1051,8 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf | |||
1044 | 1051 | ||
1045 | case JFFS2_NODETYPE_DIRENT: | 1052 | case JFFS2_NODETYPE_DIRENT: |
1046 | 1053 | ||
1047 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_dirent)) { | 1054 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_dirent) && |
1055 | len < sizeof(struct jffs2_raw_dirent)) { | ||
1048 | err = read_more(c, ref, sizeof(struct jffs2_raw_dirent), &len, buf); | 1056 | err = read_more(c, ref, sizeof(struct jffs2_raw_dirent), &len, buf); |
1049 | if (unlikely(err)) | 1057 | if (unlikely(err)) |
1050 | goto free_out; | 1058 | goto free_out; |
@@ -1058,7 +1066,8 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf | |||
1058 | 1066 | ||
1059 | case JFFS2_NODETYPE_INODE: | 1067 | case JFFS2_NODETYPE_INODE: |
1060 | 1068 | ||
1061 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_inode)) { | 1069 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_raw_inode) && |
1070 | len < sizeof(struct jffs2_raw_inode)) { | ||
1062 | err = read_more(c, ref, sizeof(struct jffs2_raw_inode), &len, buf); | 1071 | err = read_more(c, ref, sizeof(struct jffs2_raw_inode), &len, buf); |
1063 | if (unlikely(err)) | 1072 | if (unlikely(err)) |
1064 | goto free_out; | 1073 | goto free_out; |
@@ -1071,7 +1080,8 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf | |||
1071 | break; | 1080 | break; |
1072 | 1081 | ||
1073 | default: | 1082 | default: |
1074 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_unknown_node)) { | 1083 | if (JFFS2_MIN_NODE_HEADER < sizeof(struct jffs2_unknown_node) && |
1084 | len < sizeof(struct jffs2_unknown_node)) { | ||
1075 | err = read_more(c, ref, sizeof(struct jffs2_unknown_node), &len, buf); | 1085 | err = read_more(c, ref, sizeof(struct jffs2_unknown_node), &len, buf); |
1076 | if (unlikely(err)) | 1086 | if (unlikely(err)) |
1077 | goto free_out; | 1087 | goto free_out; |