ext4 crypto: fix memleak in ext4_readdir()
Kirill Tkhai [Tue, 16 Feb 2016 05:20:19 +0000 (00:20 -0500)]
When ext4_bread() fails, fname_crypto_str remains
allocated after return. Fix that.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
CC: Dmitry Monakhov <dmonakhov@virtuozzo.com>
Signed-off-by: Theodore Ts'o <tytso@google.com>
Change-Id: Ie137cb7be090c52c65c65872035b537ece8c2f17
Reviewed-on: http://git-master/r/1154521
Reviewed-by: Ian Chang <ianc@nvidia.com>
Tested-by: Ian Chang <ianc@nvidia.com>

fs/ext4/dir.c

index c3230fb..e52b121 100644 (file)
@@ -167,8 +167,11 @@ static int ext4_readdir2(struct file *file, struct dir_context *ctx)
                                        index, 1);
                        file->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT;
                        bh = ext4_bread(NULL, inode, map.m_lblk, 0);
-                       if (IS_ERR(bh))
-                               return PTR_ERR(bh);
+                       if (IS_ERR(bh)) {
+                               err = PTR_ERR(bh);
+                               bh = NULL;
+                               goto errout;
+                       }
                }
 
                if (!bh) {