Skip to content

Commit

Permalink
locks: fix leaks on setlease errors
Browse files Browse the repository at this point in the history
We're depending on setlease to free the passed-in lease on failure.

Signed-off-by: J. Bruce Fields <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
J. Bruce Fields authored and torvalds committed Oct 31, 2010
1 parent 0ceaf6c commit 096657b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1371,20 +1371,22 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
struct inode *inode = dentry->d_inode;
int error, rdlease_count = 0, wrlease_count = 0;

lease = *flp;

error = -EACCES;
if ((current_fsuid() != inode->i_uid) && !capable(CAP_LEASE))
return -EACCES;
goto out;
error = -EINVAL;
if (!S_ISREG(inode->i_mode))
return -EINVAL;
goto out;
error = security_file_lock(filp, arg);
if (error)
return error;
goto out;

time_out_leases(inode);

BUG_ON(!(*flp)->fl_lmops->fl_break);

lease = *flp;

if (arg != F_UNLCK) {
error = -EAGAIN;
if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
Expand Down

0 comments on commit 096657b

Please sign in to comment.