diff options
-rw-r--r-- | fs/ubifs/key.h | 14 | ||||
-rw-r--r-- | fs/ubifs/scan.c | 5 | ||||
-rw-r--r-- | fs/ubifs/tnc.c | 5 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 6 |
4 files changed, 27 insertions, 3 deletions
diff --git a/fs/ubifs/key.h b/fs/ubifs/key.h index 0f530c684f0b..92a8491a8f8c 100644 --- a/fs/ubifs/key.h +++ b/fs/ubifs/key.h | |||
@@ -306,6 +306,20 @@ static inline void trun_key_init(const struct ubifs_info *c, | |||
306 | } | 306 | } |
307 | 307 | ||
308 | /** | 308 | /** |
309 | * invalid_key_init - initialize invalid node key. | ||
310 | * @c: UBIFS file-system description object | ||
311 | * @key: key to initialize | ||
312 | * | ||
313 | * This is a helper function which marks a @key object as invalid. | ||
314 | */ | ||
315 | static inline void invalid_key_init(const struct ubifs_info *c, | ||
316 | union ubifs_key *key) | ||
317 | { | ||
318 | key->u32[0] = 0xDEADBEAF; | ||
319 | key->u32[1] = UBIFS_INVALID_KEY; | ||
320 | } | ||
321 | |||
322 | /** | ||
309 | * key_type - get key type. | 323 | * key_type - get key type. |
310 | * @c: UBIFS file-system description object | 324 | * @c: UBIFS file-system description object |
311 | * @key: key to get type of | 325 | * @key: key to get type of |
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index a0a305ca61af..3e1ee57dbeaa 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
@@ -197,7 +197,7 @@ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, | |||
197 | struct ubifs_ino_node *ino = buf; | 197 | struct ubifs_ino_node *ino = buf; |
198 | struct ubifs_scan_node *snod; | 198 | struct ubifs_scan_node *snod; |
199 | 199 | ||
200 | snod = kzalloc(sizeof(struct ubifs_scan_node), GFP_NOFS); | 200 | snod = kmalloc(sizeof(struct ubifs_scan_node), GFP_NOFS); |
201 | if (!snod) | 201 | if (!snod) |
202 | return -ENOMEM; | 202 | return -ENOMEM; |
203 | 203 | ||
@@ -218,6 +218,9 @@ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, | |||
218 | */ | 218 | */ |
219 | key_read(c, &ino->key, &snod->key); | 219 | key_read(c, &ino->key, &snod->key); |
220 | break; | 220 | break; |
221 | default: | ||
222 | invalid_key_init(c, &snod->key); | ||
223 | break; | ||
221 | } | 224 | } |
222 | list_add_tail(&snod->list, &sleb->nodes); | 225 | list_add_tail(&snod->list, &sleb->nodes); |
223 | sleb->nodes_cnt += 1; | 226 | sleb->nodes_cnt += 1; |
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 2194915220e5..ad9cf0133622 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
@@ -1177,6 +1177,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, | |||
1177 | unsigned long time = get_seconds(); | 1177 | unsigned long time = get_seconds(); |
1178 | 1178 | ||
1179 | dbg_tnc("search key %s", DBGKEY(key)); | 1179 | dbg_tnc("search key %s", DBGKEY(key)); |
1180 | ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); | ||
1180 | 1181 | ||
1181 | znode = c->zroot.znode; | 1182 | znode = c->zroot.znode; |
1182 | if (unlikely(!znode)) { | 1183 | if (unlikely(!znode)) { |
@@ -2966,7 +2967,7 @@ static struct ubifs_znode *right_znode(struct ubifs_info *c, | |||
2966 | * | 2967 | * |
2967 | * This function searches an indexing node by its first key @key and its | 2968 | * This function searches an indexing node by its first key @key and its |
2968 | * address @lnum:@offs. It looks up the indexing tree by pulling all indexing | 2969 | * address @lnum:@offs. It looks up the indexing tree by pulling all indexing |
2969 | * nodes it traverses to TNC. This function is called fro indexing nodes which | 2970 | * nodes it traverses to TNC. This function is called for indexing nodes which |
2970 | * were found on the media by scanning, for example when garbage-collecting or | 2971 | * were found on the media by scanning, for example when garbage-collecting or |
2971 | * when doing in-the-gaps commit. This means that the indexing node which is | 2972 | * when doing in-the-gaps commit. This means that the indexing node which is |
2972 | * looked for does not have to have exactly the same leftmost key @key, because | 2973 | * looked for does not have to have exactly the same leftmost key @key, because |
@@ -2988,6 +2989,8 @@ static struct ubifs_znode *lookup_znode(struct ubifs_info *c, | |||
2988 | struct ubifs_znode *znode, *zn; | 2989 | struct ubifs_znode *znode, *zn; |
2989 | int n, nn; | 2990 | int n, nn; |
2990 | 2991 | ||
2992 | ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); | ||
2993 | |||
2991 | /* | 2994 | /* |
2992 | * The arguments have probably been read off flash, so don't assume | 2995 | * The arguments have probably been read off flash, so don't assume |
2993 | * they are valid. | 2996 | * they are valid. |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 0c9876b396dd..c4dc9b18f73e 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -119,8 +119,12 @@ | |||
119 | * in TNC. However, when replaying, it is handy to introduce fake "truncation" | 119 | * in TNC. However, when replaying, it is handy to introduce fake "truncation" |
120 | * keys for truncation nodes because the code becomes simpler. So we define | 120 | * keys for truncation nodes because the code becomes simpler. So we define |
121 | * %UBIFS_TRUN_KEY type. | 121 | * %UBIFS_TRUN_KEY type. |
122 | * | ||
123 | * But otherwise, out of the journal reply scope, the truncation keys are | ||
124 | * invalid. | ||
122 | */ | 125 | */ |
123 | #define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT | 126 | #define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT |
127 | #define UBIFS_INVALID_KEY UBIFS_KEY_TYPES_CNT | ||
124 | 128 | ||
125 | /* | 129 | /* |
126 | * How much a directory entry/extended attribute entry adds to the parent/host | 130 | * How much a directory entry/extended attribute entry adds to the parent/host |