Skip to contentSkip to conversation

ext4: fix unbalanced up_write() in ext4_ext_truncate() error path

PATCH Applied Eric Gouriou 2 participants 2 messages May 10, 2011 – May 23, 2011 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: fix unbalanced up_write() in ext4_ext_truncate() error path

ext4_ext_truncate() should not invoke up_write(&EXT4_I(inode)->i_data_sem) when ext4_orphan_add() returns an error, as it hasn't performed a down_write() yet. This trivial patch fixes this by moving the up_write() invocation above the out_stop label.

---
 fs/ext4/extents.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/ext4/extents.c +2 -1
index e363f21..ae3c9e6 100644
@@ -3443,8 +3443,9 @@ void ext4_ext_truncate(struct inode *inode)
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
 
-out_stop:
 	up_write(&EXT4_I(inode)->i_data_sem);
+
+out_stop:
 	/*
 	 * If this was a simple ftruncate() and the file will remain alive,
 	 * then we need to clear up the orphan record which we created above.
Signature · 1 line
1.7.3.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Eric Gouriou

ext4_ext_truncate() should not invoke up_write(&EXT4_I(inode)->i_data_sem) when ext4_orphan_add() returns an error, as it hasn't performed a down_write() yet. This trivial patch fixes this by moving the up_write() invocation above the out_stop label.

Thanks, applied to the ext4 tree!

- Ted