]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit8a7f3b4d5b6c73576c68373480df20405316af59
treea6568e196571ab911c819d7f28b25ffec9408368
parent4d12eb50455169445883967409f9de42c3d6d556
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