From: Kent Overstreet Date: Sun, 29 Nov 2020 21:00:47 +0000 (-0500) Subject: bcachefs: Fix for __readahead_batch getting partial batch X-Git-Tag: v6.7-rc1~201^2~1900 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89931472c20bee93c6bcb0df7b057edda6473381;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Fix for __readahead_batch getting partial batch We were incorrectly ignoring the return value of __readahead_batch, leading to a null ptr deref in __bch2_page_state_create(). Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 1afdd775ffb3b..9c3b11f414b5e 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -667,7 +667,7 @@ static int readpages_iter_init(struct readpages_iter *iter, if (!iter->pages) return -ENOMEM; - __readahead_batch(ractl, iter->pages, nr_pages); + nr_pages = __readahead_batch(ractl, iter->pages, nr_pages); for (i = 0; i < nr_pages; i++) { __bch2_page_state_create(iter->pages[i], __GFP_NOFAIL); put_page(iter->pages[i]);