Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Miloslav Brada <email@miloslavbrada.cz>
Cc: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
	linux-sound@vger.kernel.org,
	Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Subject: Re: [BUG] ALSA: usb-audio: list_add corruption in push_back_to_ready_list() on 7.3.4
Date: Wed, 25 Nov 2026 08:14:35 +0100	[thread overview]
Message-ID: <87tsl58js4.wl-tiwai@suse.de> (raw)
In-Reply-To: <awZs88beIhMcOchv@genesis.transkript.cz>

On Wed, 25 Nov 2026 06:06:59 +0100,
Miloslav Brada wrote:
(snip)
> Possible fix (untested, only a sketch)
> --------------------------------------
> 
> 1) Check the state again under ep->lock. stop_urbs() changes the state
>    before it takes ep->lock to flush the list, so any push that takes
>    the lock after the flush sees !running:
> 
> 	static void push_back_to_ready_list(struct snd_usb_endpoint *ep,
> 					    struct snd_urb_ctx *ctx)
> 	{
> 		guard(spinlock_irqsave)(&ep->lock);
> 		/* don't re-queue after stop_urbs() flushed the list */
> 		if (!ep_state_running(ep))
> 			return;
> 		if (list_empty(&ctx->ready_list))
> 			list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs);
> 	}
> 
>    (snd_usb_endpoint_start() sets RUNNING before its fill_rest loop,
>    so that caller is not affected.)

Yes, this should cover in your particular case, and that'll be likely
the easiest fix for now.  Could you check the below?

But for a long-term solution, we'd need to improve the EP state change
and link change more tightly covered by the proper locking instead of
the current atomic check.


thanks,

Takashi

--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -449,6 +449,9 @@ static void push_back_to_ready_list(struct snd_usb_endpoint *ep,
 				    struct snd_urb_ctx *ctx)
 {
 	guard(spinlock_irqsave)(&ep->lock);
+	/* don't re-queue after stop_urbs() flushed the list */
+	if (!ep_state_running(ep))
+		return;
 	/* ctx may still be linked: a stale completion racing a stop/restart. */
 	if (list_empty(&ctx->ready_list))
 		list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs);

      reply	other threads:[~2026-11-25  7:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  5:06 [BUG] ALSA: usb-audio: list_add corruption in push_back_to_ready_list() on 7.3.4 Miloslav Brada
2026-11-25  7:14 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tsl58js4.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=email@miloslavbrada.cz \
    --cc=linux-sound@vger.kernel.org \
    --cc=ngocthang2710.1999@gmail.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox