diff options
author | Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com> | 2017-06-24 02:37:21 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2017-07-13 13:45:08 +0200 |
commit | 4d9bcaddacf23861c5ee088b0c03e7034c3d59d6 (patch) | |
tree | e2a78e2ba45bf86d738e409ee1573822ddc36a11 /fs/ext2 | |
parent | reiserfs: fix race in prealloc discard (diff) | |
download | linux-4d9bcaddacf23861c5ee088b0c03e7034c3d59d6.tar.xz linux-4d9bcaddacf23861c5ee088b0c03e7034c3d59d6.zip |
ext2: Fix memory leak when truncate races ext2_get_blocks
Buffer heads referencing indirect blocks may not be released if the file
is truncated at the right time. This happens because ext2_get_branch()
returns NULL when it finds the whole chain of indirect blocks already
set, and when truncate alters the chain this value of NULL is
treated as the address of the last head to be released. Handle this in the
same way as it's done after the got_it label.
Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/inode.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 2dcbd5698884..30163d007b2f 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -659,6 +659,7 @@ static int ext2_get_blocks(struct inode *inode, */ err = -EAGAIN; count = 0; + partial = chain + depth - 1; break; } blk = le32_to_cpu(*(chain[depth-1].p + count)); |