From: Jeff Layton Date: Tue, 14 Nov 2017 19:43:56 +0000 (-0500) Subject: fcntl: don't leak fd reference when fixup_compat_flock fails X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6e9c2a05c368a0b53d5b6647798e67830f5508e0;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git fcntl: don't leak fd reference when fixup_compat_flock fails [ Upstream commit 9280a601e6080c9ff658468c1c775ff6514099a6 ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/fcntl.c b/fs/fcntl.c index 8d78ffd7b399..6fd311367efc 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -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: