]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
fcntl: don't leak fd reference when fixup_compat_flock fails
authorJeff Layton <jlayton@redhat.com>
Tue, 14 Nov 2017 19:43:56 +0000 (14:43 -0500)
committerJeff Layton <jlayton@redhat.com>
Wed, 15 Nov 2017 13:08:36 +0000 (08:08 -0500)
Currently we just return err here, but we need to put the fd reference
first.

Fixes: 94073ad77fff (fs/locks: don't mess with the address limit in compat_fcntl64)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
fs/fcntl.c

index 30f47d0f74a00985149ee8123f34531643232711..e15bcc4265d0e1263c888090efe431f72120463c 100644 (file)
@@ -632,9 +632,8 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
                if (err)
                        break;
                err = fixup_compat_flock(&flock);
-               if (err)
-                       return err;
-               err = put_compat_flock(&flock, compat_ptr(arg));
+               if (!err)
+                       err = put_compat_flock(&flock, compat_ptr(arg));
                break;
        case F_GETLK64:
        case F_OFD_GETLK: