diff options
Diffstat (limited to 'fs/hfsplus/btree.c')
-rw-r--r-- | fs/hfsplus/btree.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index d4bd864ce108..82caff215e08 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c | |||
@@ -63,10 +63,23 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) | |||
63 | tree->max_key_len = be16_to_cpu(head->max_key_len); | 63 | tree->max_key_len = be16_to_cpu(head->max_key_len); |
64 | tree->depth = be16_to_cpu(head->depth); | 64 | tree->depth = be16_to_cpu(head->depth); |
65 | 65 | ||
66 | /* Set the correct compare function */ | 66 | /* Verify the tree and set the correct compare function */ |
67 | if (id == HFSPLUS_EXT_CNID) { | 67 | switch (id) { |
68 | case HFSPLUS_EXT_CNID: | ||
69 | if (tree->max_key_len != HFSPLUS_EXT_KEYLEN - sizeof(u16)) { | ||
70 | printk(KERN_ERR "hfs: invalid extent max_key_len %d\n", | ||
71 | tree->max_key_len); | ||
72 | goto fail_page; | ||
73 | } | ||
68 | tree->keycmp = hfsplus_ext_cmp_key; | 74 | tree->keycmp = hfsplus_ext_cmp_key; |
69 | } else if (id == HFSPLUS_CAT_CNID) { | 75 | break; |
76 | case HFSPLUS_CAT_CNID: | ||
77 | if (tree->max_key_len != HFSPLUS_CAT_KEYLEN - sizeof(u16)) { | ||
78 | printk(KERN_ERR "hfs: invalid catalog max_key_len %d\n", | ||
79 | tree->max_key_len); | ||
80 | goto fail_page; | ||
81 | } | ||
82 | |||
70 | if (test_bit(HFSPLUS_SB_HFSX, &HFSPLUS_SB(sb)->flags) && | 83 | if (test_bit(HFSPLUS_SB_HFSX, &HFSPLUS_SB(sb)->flags) && |
71 | (head->key_type == HFSPLUS_KEY_BINARY)) | 84 | (head->key_type == HFSPLUS_KEY_BINARY)) |
72 | tree->keycmp = hfsplus_cat_bin_cmp_key; | 85 | tree->keycmp = hfsplus_cat_bin_cmp_key; |
@@ -74,7 +87,8 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) | |||
74 | tree->keycmp = hfsplus_cat_case_cmp_key; | 87 | tree->keycmp = hfsplus_cat_case_cmp_key; |
75 | set_bit(HFSPLUS_SB_CASEFOLD, &HFSPLUS_SB(sb)->flags); | 88 | set_bit(HFSPLUS_SB_CASEFOLD, &HFSPLUS_SB(sb)->flags); |
76 | } | 89 | } |
77 | } else { | 90 | break; |
91 | default: | ||
78 | printk(KERN_ERR "hfs: unknown B*Tree requested\n"); | 92 | printk(KERN_ERR "hfs: unknown B*Tree requested\n"); |
79 | goto fail_page; | 93 | goto fail_page; |
80 | } | 94 | } |
@@ -84,6 +98,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) | |||
84 | goto fail_page; | 98 | goto fail_page; |
85 | if (!tree->node_count) | 99 | if (!tree->node_count) |
86 | goto fail_page; | 100 | goto fail_page; |
101 | |||
87 | tree->node_size_shift = ffs(size) - 1; | 102 | tree->node_size_shift = ffs(size) - 1; |
88 | 103 | ||
89 | tree->pages_per_bnode = (tree->node_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | 104 | tree->pages_per_bnode = (tree->node_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; |
@@ -93,9 +108,9 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) | |||
93 | return tree; | 108 | return tree; |
94 | 109 | ||
95 | fail_page: | 110 | fail_page: |
96 | tree->inode->i_mapping->a_ops = &hfsplus_aops; | ||
97 | page_cache_release(page); | 111 | page_cache_release(page); |
98 | free_inode: | 112 | free_inode: |
113 | tree->inode->i_mapping->a_ops = &hfsplus_aops; | ||
99 | iput(tree->inode); | 114 | iput(tree->inode); |
100 | free_tree: | 115 | free_tree: |
101 | kfree(tree); | 116 | kfree(tree); |