aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/open.c b/fs/open.c
index e27c205364d3..1d9e5e98bf4e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -256,24 +256,26 @@ static long do_sys_truncate(const char __user * path, loff_t length)
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
goto dput_and_out;
- /*
- * Make sure that there are no leases.
- */
- error = break_lease(inode, FMODE_WRITE);
+ error = get_write_access(inode);
if (error)
goto dput_and_out;
- error = get_write_access(inode);
+ /*
+ * Make sure that there are no leases. get_write_access() protects
+ * against the truncate racing with a lease-granting setlease().
+ */
+ error = break_lease(inode, FMODE_WRITE);
if (error)
- goto dput_and_out;
+ goto put_write_and_out;
error = locks_verify_truncate(inode, NULL, length);
if (!error) {
DQUOT_INIT(inode);
error = do_truncate(nd.dentry, length, 0, NULL);
}
- put_write_access(inode);
+put_write_and_out:
+ put_write_access(inode);
dput_and_out:
path_release(&nd);
out: