misc: nsm: do not unlock mutex before locking it

nsm_dev_ioctl() jumps to the common out label when the initial
copy_from_user() fails. That failure path runs before
mutex_lock(&nsm->lock), but the out label unconditionally calls
mutex_unlock(&nsm->lock).

Return -EFAULT directly for the pre-lock copy_from_user() failure so
only paths that acquired the mutex release it.

Signed-off-by: Vu Nguyen Anh Khoa <khoavna.tin.2225@gmail.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260621085743.76329-2-khoavna.tin.2225@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Vu Nguyen Anh Khoa 2026-06-21 15:57:43 +07:00 • committed by Greg Kroah-Hartman
commit 937cd823bb