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 <sallenki@codeaurora.org>
tirimbino
Sriharsha Allenki 6 years ago committed by Gerrit - the friendly Code Review server
parent 6e7c2de45c
commit 0ed84179d0
  1. 4
      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;

Loading…
Cancel
Save