Re: [PATCH 2/2] misc: nsm: do not unlock mutex before locking it

From: Graf (AWS), Alexander

Date: Sun Jun 21 2026 - 05:34:13 EST



On 21.06.26 10:57, Vu Nguyen Anh Khoa wrote:
> 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@xxxxxxxxx>


Reviewed-by: Alexander Graf <graf@xxxxxxxxxx>


Alex




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597