]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.31.8/0062-ext4-plug-a-buffer_head-leak-in-an-error-path-of-ext.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.31.8 / 0062-ext4-plug-a-buffer_head-leak-in-an-error-path-of-ext.patch
1 From a3b3756ab5968074429c05ce891a297a25f79d8e Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Sat, 14 Nov 2009 08:19:05 -0500
4 Subject: [PATCH 62/85] ext4: plug a buffer_head leak in an error path of ext4_iget()
5
6 (cherry picked from commit 567f3e9a70d71e5c9be03701b8578be77857293b)
7
8 One of the invalid error paths in ext4_iget() forgot to brelse() the
9 inode buffer head. Fix it by adding a brelse() in the common error
10 return path, which also simplifies function.
11
12 Thanks to Andi Kleen <ak@linux.intel.com> reporting the problem.
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 | 11 +++--------
18 1 file changed, 3 insertions(+), 8 deletions(-)
19
20 --- a/fs/ext4/inode.c
21 +++ b/fs/ext4/inode.c
22 @@ -4771,7 +4771,6 @@ struct inode *ext4_iget(struct super_blo
23 struct ext4_iloc iloc;
24 struct ext4_inode *raw_inode;
25 struct ext4_inode_info *ei;
26 - struct buffer_head *bh;
27 struct inode *inode;
28 long ret;
29 int block;
30 @@ -4783,11 +4782,11 @@ struct inode *ext4_iget(struct super_blo
31 return inode;
32
33 ei = EXT4_I(inode);
34 + iloc.bh = 0;
35
36 ret = __ext4_get_inode_loc(inode, &iloc, 0);
37 if (ret < 0)
38 goto bad_inode;
39 - bh = iloc.bh;
40 raw_inode = ext4_raw_inode(&iloc);
41 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
42 inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
43 @@ -4810,7 +4809,6 @@ struct inode *ext4_iget(struct super_blo
44 if (inode->i_mode == 0 ||
45 !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) {
46 /* this inode is deleted */
47 - brelse(bh);
48 ret = -ESTALE;
49 goto bad_inode;
50 }
51 @@ -4842,7 +4840,6 @@ struct inode *ext4_iget(struct super_blo
52 ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);
53 if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >
54 EXT4_INODE_SIZE(inode->i_sb)) {
55 - brelse(bh);
56 ret = -EIO;
57 goto bad_inode;
58 }
59 @@ -4895,10 +4892,8 @@ struct inode *ext4_iget(struct super_blo
60 /* Validate block references which are part of inode */
61 ret = ext4_check_inode_blockref(inode);
62 }
63 - if (ret) {
64 - brelse(bh);
65 + if (ret)
66 goto bad_inode;
67 - }
68
69 if (S_ISREG(inode->i_mode)) {
70 inode->i_op = &ext4_file_inode_operations;
71 @@ -4926,7 +4921,6 @@ struct inode *ext4_iget(struct super_blo
72 init_special_inode(inode, inode->i_mode,
73 new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
74 } else {
75 - brelse(bh);
76 ret = -EIO;
77 ext4_error(inode->i_sb, __func__,
78 "bogus i_mode (%o) for inode=%lu",
79 @@ -4939,6 +4933,7 @@ struct inode *ext4_iget(struct super_blo
80 return inode;
81
82 bad_inode:
83 + brelse(iloc.bh);
84 iget_failed(inode);
85 return ERR_PTR(ret);
86 }