Skip to content

Commit

Permalink
ext4: fix unbalanced up_write() in ext4_ext_truncate() error path
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Eric Gouriou <egouriou@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Eric Gouriou authored and Theodore Ts'o committed May 23, 2011
1 parent 77f4135 commit f6d2f6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -3450,8 +3450,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.
Expand Down

0 comments on commit f6d2f6b

Please sign in to comment.