add patch iterate-over-buffer-heads-correctly-in-move_extent_per_page
[ext4-patch-queue.git] / fix-memleak-in-ext4_readdir
blobdf67e55738cb9aa4071bbb560a0a934662d2c2d8
1 ext4 crypto: fix memleak in ext4_readdir()
3 From: Kirill Tkhai <ktkhai@virtuozzo.com>
5 When ext4_bread() fails, fname_crypto_str remains
6 allocated after return. Fix that.
8 Cc: Dmitry Monakhov <dmonakhov@virtuozzo.com>
9 Cc: stable@vger.kernel.org
10 Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 ---
13  fs/ext4/dir.c |    7 +++++--
14  1 file changed, 5 insertions(+), 2 deletions(-)
16 diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
17 index 1d1bca7..def3215 100644
18 --- a/fs/ext4/dir.c
19 +++ b/fs/ext4/dir.c
20 @@ -157,8 +157,11 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
21                                         index, 1);
22                         file->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT;
23                         bh = ext4_bread(NULL, inode, map.m_lblk, 0);
24 -                       if (IS_ERR(bh))
25 -                               return PTR_ERR(bh);
26 +                       if (IS_ERR(bh)) {
27 +                               err = PTR_ERR(bh);
28 +                               bh = NULL;
29 +                               goto errout;
30 +                       }
31                 }
33                 if (!bh) {