]> git.ipfire.org Git - thirdparty/linux.git/commit - fs/locks.c
fs/lock: Don't allocate file_lock in flock_make_lock().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Sun, 17 Jul 2022 04:35:31 +0000 (21:35 -0700)
committerJeff Layton <jlayton@kernel.org>
Mon, 18 Jul 2022 14:01:41 +0000 (10:01 -0400)
commit4149be7bda7e1b922896599dd9cee7a3ed8cf38b
treea6568e196571ab911c819d7f28b25ffec9408368
parentff6992735ade75aae3e35d16b17da1008d753d28
fs/lock: Don't allocate file_lock in flock_make_lock().

Two functions, flock syscall and locks_remove_flock(), call
flock_make_lock().  It allocates struct file_lock from slab
cache if its argument fl is NULL.

When we call flock syscall, we pass NULL to allocate memory
for struct file_lock.  However, we always free it at the end
by locks_free_lock().  We need not allocate it and instead
should use a local variable as locks_remove_flock() does.

Also, the validation for flock_translate_cmd() is not necessary
for locks_remove_flock().  So we move the part to flock syscall
and make flock_make_lock() return nothing.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/locks.c