[PATCH next] USB: chaoskey: fix deadlock in release

Dan Carpenter posted 1 patch 1 month, 2 weeks ago
drivers/usb/misc/chaoskey.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH next] USB: chaoskey: fix deadlock in release
Posted by Dan Carpenter 1 month, 2 weeks ago
This lock should was intended to be an unlock.  It will lead to a hang.

Fixes: 422dc0a4d12d ("USB: chaoskey: fail open after removal")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
From static analysis.  Not tested.

 drivers/usb/misc/chaoskey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index e8b63df5f975..4025f386ba6b 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -319,7 +319,7 @@ static int chaoskey_release(struct inode *inode, struct file *file)
 bail:
 	mutex_unlock(&dev->lock);
 destruction:
-	mutex_lock(&chaoskey_list_lock);
+	mutex_unlock(&chaoskey_list_lock);
 	usb_dbg(interface, "release success");
 	return rv;
 }
-- 
2.45.2
Re: [PATCH next] USB: chaoskey: fix deadlock in release
Posted by Greg Kroah-Hartman 1 month, 2 weeks ago
On Fri, Oct 11, 2024 at 10:43:50PM +0300, Dan Carpenter wrote:
> This lock should was intended to be an unlock.  It will lead to a hang.
> 
> Fixes: 422dc0a4d12d ("USB: chaoskey: fail open after removal")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> >From static analysis.  Not tested.
> 
>  drivers/usb/misc/chaoskey.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
> index e8b63df5f975..4025f386ba6b 100644
> --- a/drivers/usb/misc/chaoskey.c
> +++ b/drivers/usb/misc/chaoskey.c
> @@ -319,7 +319,7 @@ static int chaoskey_release(struct inode *inode, struct file *file)
>  bail:
>  	mutex_unlock(&dev->lock);
>  destruction:
> -	mutex_lock(&chaoskey_list_lock);
> +	mutex_unlock(&chaoskey_list_lock);
>  	usb_dbg(interface, "release success");
>  	return rv;
>  }
> -- 

The commit at:
	https://lore.kernel.org/r/tencent_84EB865C89862EC22EE94CB3A7C706C59206@qq.com
was tested, so I'll take that one :)

thanks,

greg k-h