Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a38597cc authored by Sriharsha Allenki's avatar Sriharsha Allenki Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarSriharsha Allenki <sallenki@codeaurora.org>
parent 2733ec30
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1160,19 +1160,19 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,


response:
response:
	if (!req_msg->enable && (ret != -EINVAL || ret != -ENODEV)) {
	if (!req_msg->enable && (ret != -EINVAL || ret != -ENODEV)) {
		if (info_idx >= 0) {
		mutex_lock(&chip->dev_lock);
		mutex_lock(&chip->dev_lock);
		if (info_idx >= 0) {
			info = &uadev[pcm_card_num].info[info_idx];
			info = &uadev[pcm_card_num].info[info_idx];
			uaudio_dev_intf_cleanup(
			uaudio_dev_intf_cleanup(
					uadev[pcm_card_num].udev,
					uadev[pcm_card_num].udev,
					info);
					info);
			uaudio_dbg("release resources: intf# %d card# %d\n",
			uaudio_dbg("release resources: intf# %d card# %d\n",
					subs->interface, pcm_card_num);
					subs->interface, pcm_card_num);
			mutex_unlock(&chip->dev_lock);
		}
		}
		if (atomic_read(&uadev[pcm_card_num].in_use))
		if (atomic_read(&uadev[pcm_card_num].in_use))
			kref_put(&uadev[pcm_card_num].kref,
			kref_put(&uadev[pcm_card_num].kref,
					uaudio_dev_release);
					uaudio_dev_release);
		mutex_unlock(&chip->dev_lock);
	}
	}


	resp.usb_token = req_msg->usb_token;
	resp.usb_token = req_msg->usb_token;