Update crypto-fix-validate-when-key-add-remove
[ext4-patch-queue.git] / fix-memleak-in-ext4_readdir
bloba8f5a16e5e251d200ad1f4b4a18a61d4580c14ec
1 ext4: 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 Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 CC: Dmitry Monakhov <dmonakhov@virtuozzo.com>
11 ---
12  fs/ext4/dir.c |    7 +++++--
13  1 file changed, 5 insertions(+), 2 deletions(-)
15 diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
16 index 1d1bca7..def3215 100644
17 --- a/fs/ext4/dir.c
18 +++ b/fs/ext4/dir.c
19 @@ -157,8 +157,11 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
20                                         index, 1);
21                         file->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT;
22                         bh = ext4_bread(NULL, inode, map.m_lblk, 0);
23 -                       if (IS_ERR(bh))
24 -                               return PTR_ERR(bh);
25 +                       if (IS_ERR(bh)) {
26 +                               err = PTR_ERR(bh);
27 +                               bh = NULL;
28 +                               goto errout;
29 +                       }
30                 }
32                 if (!bh) {