[PATCH v3] ALSA: usb: qcom: Adjust mutex unlock order

Erick Karanja posted 1 patch 2 months, 2 weeks ago
sound/usb/qcom/qc_audio_offload.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH v3] ALSA: usb: qcom: Adjust mutex unlock order
Posted by Erick Karanja 2 months, 2 weeks ago
The mutexes qdev_mutex and chip->mutex are acquired in that order
throughout the driver. To preserve proper lock hierarchy and avoid
potential deadlocks, they must be released in the reverse
order of acquisition.

This change reorders the unlock sequence to first release chip->mutex
followed by qdev_mutex, ensuring consistency with the locking pattern.

Fixes: e2710ea98124 ("staging: sound: Adjust mutex unlock order")

changes since v2:
 - Use a proper subject prefix and add the fixes tag.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 sound/usb/qcom/qc_audio_offload.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c
index 3543b5a53592..711f5612a83a 100644
--- a/sound/usb/qcom/qc_audio_offload.c
+++ b/sound/usb/qcom/qc_audio_offload.c
@@ -825,8 +825,8 @@ static int uaudio_sideband_notifier(struct usb_interface *intf,
 		}
 	}
 
-	mutex_unlock(&qdev_mutex);
 	mutex_unlock(&chip->mutex);
+	mutex_unlock(&qdev_mutex);
 
 	return 0;
 }
@@ -1865,8 +1865,8 @@ static void qc_usb_audio_offload_disconnect(struct snd_usb_audio *chip)
 
 	/* Device has already been cleaned up, or never populated */
 	if (!dev->chip) {
-		mutex_unlock(&qdev_mutex);
 		mutex_unlock(&chip->mutex);
+		mutex_unlock(&qdev_mutex);
 		return;
 	}
 
@@ -1921,8 +1921,8 @@ static void qc_usb_audio_offload_suspend(struct usb_interface *intf,
 
 	uaudio_send_disconnect_ind(chip);
 
+        mutex_unlock(&chip->mutex);
 	mutex_unlock(&qdev_mutex);
-	mutex_unlock(&chip->mutex);
 }
 
 static struct snd_usb_platform_ops offload_ops = {
-- 
2.43.0
Re: [PATCH v3] ALSA: usb: qcom: Adjust mutex unlock order
Posted by Takashi Iwai 2 months, 2 weeks ago
On Fri, 18 Jul 2025 09:03:08 +0200,
Erick Karanja wrote:
> 
> The mutexes qdev_mutex and chip->mutex are acquired in that order
> throughout the driver. To preserve proper lock hierarchy and avoid
> potential deadlocks, they must be released in the reverse
> order of acquisition.
> 
> This change reorders the unlock sequence to first release chip->mutex
> followed by qdev_mutex, ensuring consistency with the locking pattern.
> 
> Fixes: e2710ea98124 ("staging: sound: Adjust mutex unlock order")

This commit ID doesn't exist, and the commit summary doesn't sound
right.  You need to put the commit to be fixed with the commit summary
of that commit instead of your own.

Please resubmit with the proper Fixes tag.


thanks,

Takashi