aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/alloc.c
diff options
context:
space:
mode:
authorYingtai Xie <xieyingtai@huawei.com>2014-08-06 19:03:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:13 -0400
commit981035b47d7da8ba7c153ed431bf515f593853d8 (patch)
tree675aab83a7118389728f0dbcc733a3d3cf18ae8d /fs/ocfs2/alloc.c
parentc811f5f41e37d16b2839988426ffde78d2273d48 (diff)
ocfs2: correctly check the return value of ocfs2_search_extent_list
ocfs2_search_extent_list may return -1, so we should check the return value in ocfs2_split_and_insert, otherwise it may cause array index out of bound. And ocfs2_search_extent_list can only return value less than el->l_next_free_rec, so check if it is equal or larger than le16_to_cpu(el->l_next_free_rec) is meaningless. Signed-off-by: Yingtai Xie <xieyingtai@huawei.com> Signed-off-by: Joseph Qi <joseph.qi@huawei.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Mark Fasheh <mfasheh@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r--fs/ocfs2/alloc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 9d8fcf2f3b94..a93bf9892256 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -4961,6 +4961,15 @@ leftright:
4961 4961
4962 el = path_leaf_el(path); 4962 el = path_leaf_el(path);
4963 split_index = ocfs2_search_extent_list(el, cpos); 4963 split_index = ocfs2_search_extent_list(el, cpos);
4964 if (split_index == -1) {
4965 ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
4966 "Owner %llu has an extent at cpos %u "
4967 "which can no longer be found.\n",
4968 (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
4969 cpos);
4970 ret = -EROFS;
4971 goto out;
4972 }
4964 goto leftright; 4973 goto leftright;
4965 } 4974 }
4966out: 4975out:
@@ -5135,7 +5144,7 @@ int ocfs2_change_extent_flag(handle_t *handle,
5135 el = path_leaf_el(left_path); 5144 el = path_leaf_el(left_path);
5136 5145
5137 index = ocfs2_search_extent_list(el, cpos); 5146 index = ocfs2_search_extent_list(el, cpos);
5138 if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) { 5147 if (index == -1) {
5139 ocfs2_error(sb, 5148 ocfs2_error(sb,
5140 "Owner %llu has an extent at cpos %u which can no " 5149 "Owner %llu has an extent at cpos %u which can no "
5141 "longer be found.\n", 5150 "longer be found.\n",
@@ -5491,7 +5500,7 @@ int ocfs2_remove_extent(handle_t *handle,
5491 5500
5492 el = path_leaf_el(path); 5501 el = path_leaf_el(path);
5493 index = ocfs2_search_extent_list(el, cpos); 5502 index = ocfs2_search_extent_list(el, cpos);
5494 if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) { 5503 if (index == -1) {
5495 ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), 5504 ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
5496 "Owner %llu has an extent at cpos %u which can no " 5505 "Owner %llu has an extent at cpos %u which can no "
5497 "longer be found.\n", 5506 "longer be found.\n",
@@ -5557,7 +5566,7 @@ int ocfs2_remove_extent(handle_t *handle,
5557 5566
5558 el = path_leaf_el(path); 5567 el = path_leaf_el(path);
5559 index = ocfs2_search_extent_list(el, cpos); 5568 index = ocfs2_search_extent_list(el, cpos);
5560 if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) { 5569 if (index == -1) {
5561 ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), 5570 ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
5562 "Owner %llu: split at cpos %u lost record.", 5571 "Owner %llu: split at cpos %u lost record.",
5563 (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), 5572 (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),