Commit 096657b6 authored by J. Bruce Fields's avatar J. Bruce Fields Committed by Linus Torvalds

locks: fix leaks on setlease errors

We're depending on setlease to free the passed-in lease on failure.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0ceaf6c7
...@@ -1371,20 +1371,22 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) ...@@ -1371,20 +1371,22 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int error, rdlease_count = 0, wrlease_count = 0; int error, rdlease_count = 0, wrlease_count = 0;
lease = *flp;
error = -EACCES;
if ((current_fsuid() != inode->i_uid) && !capable(CAP_LEASE)) if ((current_fsuid() != inode->i_uid) && !capable(CAP_LEASE))
return -EACCES; goto out;
error = -EINVAL;
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return -EINVAL; goto out;
error = security_file_lock(filp, arg); error = security_file_lock(filp, arg);
if (error) if (error)
return error; goto out;
time_out_leases(inode); time_out_leases(inode);
BUG_ON(!(*flp)->fl_lmops->fl_break); BUG_ON(!(*flp)->fl_lmops->fl_break);
lease = *flp;
if (arg != F_UNLCK) { if (arg != F_UNLCK) {
error = -EAGAIN; error = -EAGAIN;
if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
......
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