]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: usb-audio: qcom: Adjust mutex unlock order
authorErick Karanja <karanja99erick@gmail.com>
Mon, 21 Jul 2025 11:45:53 +0000 (14:45 +0300)
committerTakashi Iwai <tiwai@suse.de>
Tue, 22 Jul 2025 09:39:40 +0000 (11:39 +0200)
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.

[ fixed the code indentations and Fixes tag by tiwai ]

Fixes: 326bbc348298a ("ALSA: usb-audio: qcom: Introduce QC USB SND offloading support")
Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
Link: https://patch.msgid.link/20250721114554.1666104-1-karanja99erick@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/qcom/qc_audio_offload.c

index 3543b5a535927a6cfd8b54d03bb057910c468b64..a25c5a5316901cbfa8d9c1dae369cacd7581d41e 100644 (file)
@@ -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(&qdev_mutex);
        mutex_unlock(&chip->mutex);
+       mutex_unlock(&qdev_mutex);
 }
 
 static struct snd_usb_platform_ops offload_ops = {