diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 3d7a35d6a18b..c4c056ffafde 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -33,7 +33,11 @@ static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off) int rbound, lbound, j; lbound = 0; - rbound = ih_entry_count(ih) - 1; + if (ih_location(ih) + ih_entry_count(ih) * IH_SIZE >= + de->de_bh->b_size) + rbound = (de->de_bh->b_size - ih_location(ih)) / IH_SIZE - 1; + else + rbound = ih_entry_count(ih) - 1; for (j = (rbound + lbound) / 2; lbound <= rbound; j = (rbound + lbound) / 2) {