]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.31.8/0050-ext4-fix-a-BUG_ON-crash-by-checking-that-page-has-bu.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.31.8 / 0050-ext4-fix-a-BUG_ON-crash-by-checking-that-page-has-bu.patch
1 From 7fcfa625f4bdba955d0fb0b717dc576b1e48b470 Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Wed, 30 Sep 2009 22:57:41 -0400
4 Subject: [PATCH 50/85] ext4: fix a BUG_ON crash by checking that page has buffers attached to it
5
6 (cherry picked from commit 1f94533d9cd75f6d2826018d54a971b9cc085992)
7
8 In ext4_num_dirty_pages() we were calling page_buffers() before
9 checking to see if the page actually had pages attached to it; this
10 would cause a BUG check crash in the inline function page_buffers().
11
12 Thanks to Markus Trippelsdorf for reporting this bug.
13
14 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16 ---
17 fs/ext4/inode.c | 22 +++++++++++-----------
18 1 file changed, 11 insertions(+), 11 deletions(-)
19
20 --- a/fs/ext4/inode.c
21 +++ b/fs/ext4/inode.c
22 @@ -1147,8 +1147,8 @@ static int check_block_validity(struct i
23 }
24
25 /*
26 - * Return the number of dirty pages in the given inode starting at
27 - * page frame idx.
28 + * Return the number of contiguous dirty pages in a given inode
29 + * starting at page frame idx.
30 */
31 static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx,
32 unsigned int max_pages)
33 @@ -1182,15 +1182,15 @@ static pgoff_t ext4_num_dirty_pages(stru
34 unlock_page(page);
35 break;
36 }
37 - head = page_buffers(page);
38 - bh = head;
39 - do {
40 - if (!buffer_delay(bh) &&
41 - !buffer_unwritten(bh)) {
42 - done = 1;
43 - break;
44 - }
45 - } while ((bh = bh->b_this_page) != head);
46 + if (page_has_buffers(page)) {
47 + bh = head = page_buffers(page);
48 + do {
49 + if (!buffer_delay(bh) &&
50 + !buffer_unwritten(bh))
51 + done = 1;
52 + bh = bh->b_this_page;
53 + } while (!done && (bh != head));
54 + }
55 unlock_page(page);
56 if (done)
57 break;