Skip to contentSkip to conversation

FAILED: patch "[PATCH] ALSA: usx2y: Refuse a retried DSP load after a failure" failed to apply to 5.10-stable tree

PATCH Applied Sasha Levin 2 participants 3 messages Nov 10 – Nov 11

Subsystems (2)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 1f8101b6adc87a3ddbd51fcb6609251591758026
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From 1f8101b6adc87a3ddbd51fcb6609251591758026 Mon Sep 17 00:00:00 2001
From: YuanZhe Liu <[email protected]>
Date: Sun, 1 Nov 2026 03:15:57 +0800
Subject: [PATCH] ALSA: usx2y: Refuse a retried DSP load after a failure

snd_usx2y_hwdep_dsp_load() sets up the asynchronous sequence URBs and the interrupt URB when the FPGA firmware image with index 1 is loaded, and then creates the ALSA devices. If usx2y_in04_init() or usx2y_create_alsa_devices() fails, the URBs that were already set up are left in place.

The core keeps the index unloaded when the callback fails, so user space may issue the same request again. The second attempt then enters usx2y_async_seq04_init() or usx2y_in04_init() with the URBs still allocated and trips WARN_ON(usx2y->as04.buffer) or WARN_ON(usx2y->in04_urb).

The URBs cannot be released at this point: the card may already have registered PCM devices that user space can still open, and the disconnect handler accesses the URBs without holding the DSP lock. Mark the chip as hung instead, so that a retried request is refused with -ENODEV and the assertions keep their meaning. The URBs are released by snd_usx2y_card_private_free() when the card is freed.

A failing usx2y_async_seq04_init() still releases its own URBs, so that path remains retryable.

---
 sound/usb/usx2y/usX2Yhwdep.c | 5 +++++
 1 file changed, 5 insertions(+)
sound/usb/usx2y/usX2Yhwdep.c +5 -0
index 7f153a2fcdd81..3800c5b5887c8 100644
@@ -179,6 +179,9 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
 	int lret, err;
 	char *buf;
 
+	if (priv->chip_status & USX2Y_STAT_CHIP_HUP)
+		return -ENODEV;
+
 	buf = memdup_user(dsp->image, dsp->length);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
@@ -201,11 +204,13 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
 		err = usx2y_in04_init(priv);
 		if (err) {
 			dev_err(&dev->dev, "usx2y_in04_init error\n");
+			priv->chip_status |= USX2Y_STAT_CHIP_HUP;
 			return err;
 		}
 		err = usx2y_create_alsa_devices(hw->card);
 		if (err) {
 			dev_err(&dev->dev, "usx2y_create_alsa_devices error %i\n", err);
+			priv->chip_status |= USX2Y_STAT_CHIP_HUP;
 			return err;
 		}
 		priv->chip_status |= USX2Y_STAT_CHIP_INIT;
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/1 ALSA: usx2y: Refuse a retried DSP load after a failure

snd_usx2y_hwdep_dsp_load() sets up the asynchronous sequence URBs and the interrupt URB when the FPGA firmware image with index 1 is loaded, and then creates the ALSA devices. If usx2y_in04_init() or usx2y_create_alsa_devices() fails, the URBs that were already set up are left in place.

The core keeps the index unloaded when the callback fails, so user space may issue the same request again. The second attempt then enters usx2y_async_seq04_init() or usx2y_in04_init() with the URBs still allocated and trips WARN_ON(usx2y->as04.buffer) or WARN_ON(usx2y->in04_urb).

The URBs cannot be released at this point: the card may already have registered PCM devices that user space can still open, and the disconnect handler accesses the URBs without holding the DSP lock. Mark the chip as hung instead, so that a retried request is refused with -ENODEV and the assertions keep their meaning. The URBs are released by snd_usx2y_card_private_free() when the card is freed.

A failing usx2y_async_seq04_init() still releases its own URBs, so that path remains retryable.

In 5.10 a failure of usx2y_create_alsa_devices() frees the card, so there is no retry to refuse on that path and only usx2y_in04_init() is marked as hung here.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
(cherry picked from commit 1f8101b6adc87a3ddbd51fcb6609251591758026)
---
 sound/usb/usx2y/usX2Yhwdep.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/usb/usx2y/usX2Yhwdep.c +4 -0
index eeafe580d..50c03e6cd 100644
@@ -193,6 +193,9 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
 	int lret, err;
 	char *buf;
 
+	if (priv->chip_status & USX2Y_STAT_CHIP_HUP)
+		return -ENODEV;
+
 	snd_printdd("dsp_load %s\n", dsp->name);
 
 	buf = memdup_user(dsp->image, dsp->length);
@@ -217,6 +220,7 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,
 		err = usx2y_in04_init(priv);
 		if (err) {
 			snd_printk(KERN_ERR "usx2y_in04_init error\n");
+			priv->chip_status |= USX2Y_STAT_CHIP_HUP;
 			return err;
 		}
 		err = usx2y_create_alsa_devices(hw->card);
Signature · 1 line
2.34.1
author maintainer Applied
#2 lore raw

Re: [PATCH 5.10.y] ALSA: usx2y: Refuse a retried DSP load after a failure

Quoted 1 line

[PATCH 5.10.y] ALSA: usx2y: Refuse a retried DSP load after a failure

Queued for 6.1, 5.15 and 5.10, thanks.

Signature · 2 lines
Thanks,
Sasha