Fix a bad error case handling in read_cache_page_async()
authorDavid Howells <dhowells@redhat.com>
Wed, 9 May 2007 12:42:20 +0000 (13:42 +0100)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 9 May 2007 20:04:03 +0000 (13:04 -0700)
Commit 6fe6900e1e5b6fa9e5c59aa5061f244fe3f467e2 introduced a nasty bug
in read_cache_page_async().

It added a "mark_page_accessed(page)" at the final return path in
read_cache_page_async().  But in error cases, 'page' holds the error
code, and you can't mark it accessed.

[ and Glauber de Oliveira Costa points out that we can use a return
  instead of adding more goto's ]

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/filemap.c

index 9e56fd1..7b48b2a 100644 (file)
@@ -1784,7 +1784,7 @@ struct page *read_cache_page_async(struct address_space *mapping,
 retry:
        page = __read_cache_page(mapping, index, filler, data);
        if (IS_ERR(page))
-               goto out;
+               return page;
        mark_page_accessed(page);
        if (PageUptodate(page))
                goto out;
@@ -1802,9 +1802,9 @@ retry:
        err = filler(data, page);
        if (err < 0) {
                page_cache_release(page);
-               page = ERR_PTR(err);
+               return ERR_PTR(err);
        }
- out:
+out:
        mark_page_accessed(page);
        return page;
 }