From: J. Bruce Fields Date: Sat, 30 Oct 2010 21:31:14 +0000 (-0400) Subject: locks: fix leaks on setlease errors X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=096657b65e1ac197e20be5ce7cff6b6ca2532787;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git locks: fix leaks on setlease errors We're depending on setlease to free the passed-in lease on failure. Signed-off-by: J. Bruce Fields Acked-by: Arnd Bergmann Signed-off-by: Linus Torvalds --- diff --git a/fs/locks.c b/fs/locks.c index 06c77734f589..63fbc41cc573 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -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))