]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
locks: fix leaks on setlease errors
authorJ. Bruce Fields <bfields@redhat.com>
Sat, 30 Oct 2010 21:31:14 +0000 (17:31 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 31 Oct 2010 01:08:15 +0000 (18:08 -0700)
We're depending on setlease to free the passed-in lease on failure.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/locks.c

index 06c77734f5894ba329232f44cd69791e20abc6f6..63fbc41cc573c0161c19ed83a1f16819acd0f7fd 100644 (file)
@@ -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))