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

Commit ca8c1852 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ALSA: usb-audio: Fix races at disconnection and PCM closing"

parents 68d22ff0 82ff00f8
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -318,6 +318,11 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)

static int snd_usb_audio_free(struct snd_usb_audio *chip)
{
	struct list_head *p, *n;

	list_for_each_safe(p, n, &chip->ep_list)
		snd_usb_endpoint_free(p);

	mutex_destroy(&chip->mutex);
	kfree(chip);
	return 0;
@@ -594,7 +599,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
				     struct snd_usb_audio *chip)
{
	struct snd_card *card;
	struct list_head *p, *n;
	struct list_head *p;

	if (chip == (void *)-1L)
		return;
@@ -607,14 +612,16 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
	mutex_lock(&register_mutex);
	chip->num_interfaces--;
	if (chip->num_interfaces <= 0) {
		struct snd_usb_endpoint *ep;

		snd_card_disconnect(card);
		/* release the pcm resources */
		list_for_each(p, &chip->pcm_list) {
			snd_usb_stream_disconnect(p);
		}
		/* release the endpoint resources */
		list_for_each_safe(p, n, &chip->ep_list) {
			snd_usb_endpoint_free(p);
		list_for_each_entry(ep, &chip->ep_list, list) {
			snd_usb_endpoint_release(ep);
		}
		/* release the midi resources */
		list_for_each(p, &chip->midi_list) {
+14 −3
Original line number Diff line number Diff line
@@ -962,20 +962,31 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep)
	return 0;
}

/**
 * snd_usb_endpoint_release: Tear down an snd_usb_endpoint
 *
 * @ep: the endpoint to release
 *
 * This function does not care for the endpoint's use count but will tear
 * down all the streaming URBs immediately.
 */
void snd_usb_endpoint_release(struct snd_usb_endpoint *ep)
{
	release_urbs(ep, 1);
}

/**
 * snd_usb_endpoint_free: Free the resources of an snd_usb_endpoint
 *
 * @ep: the list header of the endpoint to free
 *
 * This function does not care for the endpoint's use count but will tear
 * down all the streaming URBs immediately and free all resources.
 * This free all resources of the given ep.
 */
void snd_usb_endpoint_free(struct list_head *head)
{
	struct snd_usb_endpoint *ep;

	ep = list_entry(head, struct snd_usb_endpoint, list);
	release_urbs(ep, 1);
	kfree(ep);
}

+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep);
void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
int  snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
int  snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
void snd_usb_endpoint_release(struct snd_usb_endpoint *ep);
void snd_usb_endpoint_free(struct list_head *head);

int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep);