--- ram/linux-2.6.8.1/mm/filemap.c 2004-08-14 03:56:25.000000000 -0700 +++ linux-2.6.8.1/mm/filemap.c 2004-08-16 07:56:31.912038720 -0700 @@ -665,14 +665,18 @@ void do_generic_mapping_read(struct addr offset = *ppos & ~PAGE_CACHE_MASK; isize = i_size_read(inode); - end_index = isize >> PAGE_CACHE_SHIFT; - if (index > end_index) + if (!isize) goto out; + + end_index = isize >> PAGE_CACHE_SHIFT; for (;;) { struct page *page; unsigned long nr, ret; + if (index > end_index) + goto out; + cond_resched(); page_cache_readahead(mapping, &ra, filp, index);