aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/scan.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-22 00:10:12 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-30 03:19:08 -0400
commitba2f48f70efcf4d82deafb2be327ed64b1f043a5 (patch)
treea05dd8287bb6588117f2a2a921b54f8ebf3425f4 /fs/ubifs/scan.c
parent5b7a3a2e1b0cbc7d5410a8da60dac266a3e19268 (diff)
UBIFS: mark unused key objects as invalid
When scanning the flash, UBIFS builds a list of flash nodes of type 'struct ubifs_scan_node'. Each scanned node has a 'snod->key' field. This field is valid for most of the nodes, but invalid for some node type, e.g., truncation nodes. It is safer to explicitly initialize such keys to something invalid, rather than leaving them initialized to all zeros, which has key type of UBIFS_INO_KEY. This patch introduces new "fake" key type UBIFS_INVALID_KEY and initializes unused 'snod->key' objects to this type. It also adds debugging assertions in the TNC code to make sure no one ever tries to look these nodes up in the TNC. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/scan.c')
-rw-r--r--fs/ubifs/scan.c5
1 files changed, 4 insertions, 1 deletions
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;