Commit 87f77892 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] buffer_head leak

Fix buffer-head leak on truncate race.

The reason why it hadn't been triggered left right and center is that we
step on that path only when partial truncate blows away an indirect
block shared between truncated and remaining areas _and_ races with
ext2_get_block() in the beginning of said area.  IOW, we need

	* indirect block with hole in the beginning
	* get_block starting to read that block
	* truncate killing everything past the hole (and thus freeing indirect
	  block in question)
	* get_block completing the read and noticing that block is actually
	  gone.

OK...  IMO we should do that brelse() outside of the loop.
parent 9d129978
...@@ -261,6 +261,7 @@ static Indirect *ext2_get_branch(struct inode *inode, ...@@ -261,6 +261,7 @@ static Indirect *ext2_get_branch(struct inode *inode,
changed: changed:
read_unlock(&EXT2_I(inode)->i_meta_lock); read_unlock(&EXT2_I(inode)->i_meta_lock);
brelse(bh);
*err = -EAGAIN; *err = -EAGAIN;
goto no_block; goto no_block;
failure: failure:
......
...@@ -414,6 +414,7 @@ static Indirect *ext3_get_branch(struct inode *inode, int depth, int *offsets, ...@@ -414,6 +414,7 @@ static Indirect *ext3_get_branch(struct inode *inode, int depth, int *offsets,
return NULL; return NULL;
changed: changed:
brelse(bh);
*err = -EAGAIN; *err = -EAGAIN;
goto no_block; goto no_block;
failure: failure:
......
...@@ -57,6 +57,7 @@ static inline Indirect *get_branch(struct inode *inode, ...@@ -57,6 +57,7 @@ static inline Indirect *get_branch(struct inode *inode,
changed: changed:
read_unlock(&pointers_lock); read_unlock(&pointers_lock);
brelse(bh);
*err = -EAGAIN; *err = -EAGAIN;
goto no_block; goto no_block;
failure: failure:
......
...@@ -108,6 +108,7 @@ static Indirect *get_branch(struct inode *inode, ...@@ -108,6 +108,7 @@ static Indirect *get_branch(struct inode *inode,
return NULL; return NULL;
changed: changed:
brelse(bh);
*err = -EAGAIN; *err = -EAGAIN;
goto no_block; goto no_block;
failure: failure:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment