Skip to content

Commit

Permalink
radix-tree: fix radix_tree_prev_hole() underflow case
Browse files Browse the repository at this point in the history
radix_tree_prev_hole() used LONG_MAX to detect underflow; however,
ULONG_MAX is clearly what was intended, both here and by its only user
(count_history_pages at mm/readahead.c).

Reviewed-by: Wu Fengguang <[email protected]>
Signed-off-by: Cesar Eduardo Barros <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
cesarb authored and torvalds committed May 27, 2010
1 parent 9d85cba commit edcd1d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/radix-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ EXPORT_SYMBOL(radix_tree_next_hole);
*
* Returns: the index of the hole if found, otherwise returns an index
* outside of the set specified (in which case 'index - return >= max_scan'
* will be true). In rare cases of wrap-around, LONG_MAX will be returned.
* will be true). In rare cases of wrap-around, ULONG_MAX will be returned.
*
* radix_tree_next_hole may be called under rcu_read_lock. However, like
* radix_tree_gang_lookup, this will not atomically search a snapshot of
Expand All @@ -674,7 +674,7 @@ unsigned long radix_tree_prev_hole(struct radix_tree_root *root,
if (!radix_tree_lookup(root, index))
break;
index--;
if (index == LONG_MAX)
if (index == ULONG_MAX)
break;
}

Expand Down

0 comments on commit edcd1d8

Please sign in to comment.