From 0ed84179d01b3d0cbe852551053d9a1ce0ac2d54 Mon Sep 17 00:00:00 2001 From: Sriharsha Allenki Date: Wed, 3 Jul 2019 14:37:26 +0530 Subject: [PATCH] sound: usb: Fix possible race between release and cleanup In a case where the physical disconnect of headset and the disable call from QMI race with each other, there is a possibility that usb_sec_event_ring_cleanup is called at the same time from uaudio_dev_cleanup and uaudio_dev_release leading to kernel panic. Fix this by seriailizing both these calls using the dev_lock mutex. Change-Id: I88abccca704786446e0826fc60994c9580828156 Signed-off-by: Sriharsha Allenki --- sound/usb/usb_audio_qmi_svc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/usb_audio_qmi_svc.c b/sound/usb/usb_audio_qmi_svc.c index 7bb404eb7bce..307ebcf78b15 100644 --- a/sound/usb/usb_audio_qmi_svc.c +++ b/sound/usb/usb_audio_qmi_svc.c @@ -1156,17 +1156,17 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle, response: if (!req_msg->enable && ret != -EINVAL) { + mutex_lock(&chip->dev_lock); if (info_idx >= 0) { - mutex_lock(&chip->dev_lock); info = &uadev[pcm_card_num].info[info_idx]; uaudio_dev_intf_cleanup(uadev[pcm_card_num].udev, info); uaudio_dbg("release resources: intf# %d card# %d\n", subs->interface, pcm_card_num); - mutex_unlock(&chip->dev_lock); } if (atomic_read(&uadev[pcm_card_num].in_use)) kref_put(&uadev[pcm_card_num].kref, uaudio_dev_release); + mutex_unlock(&chip->dev_lock); } resp.usb_token = req_msg->usb_token;