* [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load
@ 2026-10-29 8:48 YuanZhe Liu
2026-10-29 8:48 ` [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: YuanZhe Liu @ 2026-10-29 8:48 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable
snd_hwdep_dsp_load() checks hw->dsp_loaded and then calls the driver's
dsp_load callback without any serialization. A hwdep file descriptor can
be shared among threads, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for
the same index can both pass the check and run the callback concurrently.
The snd-usb-usx2y driver then enters usx2y_async_seq04_init() twice, which
hits WARN_ON(usx2y->as04.buffer) and may also allocate the US-428
sequence URBs twice.
Patch 1 adds a per-device mutex around the check, the callback and the
bookkeeping. Patch 2 removes the WARN_ON() assertions from the usx2y
initialization helpers: a repeated request after a partially failed load
is a valid sequence from user space, so the driver should return -EBUSY
instead of warning.
YuanZhe Liu (2):
ALSA: hwdep: Serialize DSP load requests
ALSA: usx2y: Avoid WARN on a repeated DSP load
include/sound/hwdep.h | 1 +
sound/core/hwdep.c | 2 ++
sound/usb/usx2y/usbusx2y.c | 4 ++--
3 files changed, 5 insertions(+), 2 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests 2026-10-29 8:48 [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu @ 2026-10-29 8:48 ` YuanZhe Liu 2026-10-31 16:00 ` Takashi Iwai 2026-10-29 8:48 ` [PATCH 2/2] ALSA: usx2y: Avoid WARN on a repeated DSP load YuanZhe Liu 2026-10-30 17:36 ` [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu 2 siblings, 1 reply; 9+ messages in thread From: YuanZhe Liu @ 2026-10-29 8:48 UTC (permalink / raw) To: Jaroslav Kysela, Takashi Iwai Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable The check of the loaded DSP indices and the call of the driver's dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep file descriptor can be shared among threads, or inherited across fork, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both observe the index as unloaded and enter the driver's callback concurrently, even though the device itself is opened exclusively. This breaks the assumption behind hw->dsp_loaded that a firmware index is loaded only once. For example, snd-usb-usx2y hits WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may allocate the US-428 sequence URBs twice. Serialize the check, the callback invocation and the bookkeeping with a per-hwdep mutex, so that the second request returns -EBUSY. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu <byu@xidian.edu.cn> Signed-off-by: Bin Yu <byu@xidian.edu.cn> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index b0da633184cd..7357727f0660 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -57,6 +57,7 @@ struct snd_hwdep { struct mutex open_mutex; int used; /* reference counter */ + struct mutex dsp_mutex; /* serializes DSP load requests */ unsigned int dsp_loaded; /* bit fields of loaded dsp indices */ unsigned int exclusive:1; /* exclusive access mode */ }; diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index c6de5345e946..fb9034897c56 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -212,6 +212,7 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw, return -ENXIO; if (info->index >= 32) return -EINVAL; + guard(mutex)(&hw->dsp_mutex); /* check whether the dsp was already loaded */ if (hw->dsp_loaded & (1u << info->index)) return -EBUSY; @@ -380,6 +381,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, init_waitqueue_head(&hwdep->open_wait); mutex_init(&hwdep->open_mutex); + mutex_init(&hwdep->dsp_mutex); hwdep->card = card; hwdep->device = device; if (id) -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests 2026-10-29 8:48 ` [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu @ 2026-10-31 16:00 ` Takashi Iwai 0 siblings, 0 replies; 9+ messages in thread From: Takashi Iwai @ 2026-10-31 16:00 UTC (permalink / raw) To: YuanZhe Liu Cc: Jaroslav Kysela, Takashi Iwai, Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable On Thu, 29 Oct 2026 09:48:09 +0100, YuanZhe Liu wrote: > > The check of the loaded DSP indices and the call of the driver's > dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep > file descriptor can be shared among threads, or inherited across fork, > so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both > observe the index as unloaded and enter the driver's callback > concurrently, even though the device itself is opened exclusively. > > This breaks the assumption behind hw->dsp_loaded that a firmware index > is loaded only once. For example, snd-usb-usx2y hits > WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may > allocate the US-428 sequence URBs twice. > > Serialize the check, the callback invocation and the bookkeeping with a > per-hwdep mutex, so that the second request returns -EBUSY. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: stable@vger.kernel.org > Co-developed-by: Bin Yu <byu@xidian.edu.cn> > Signed-off-by: Bin Yu <byu@xidian.edu.cn> > Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> > Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> > Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> Applied this one. Thanks. Takashi ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] ALSA: usx2y: Avoid WARN on a repeated DSP load 2026-10-29 8:48 [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu 2026-10-29 8:48 ` [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu @ 2026-10-29 8:48 ` YuanZhe Liu 2026-10-31 16:00 ` Takashi Iwai 2026-10-30 17:36 ` [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu 2 siblings, 1 reply; 9+ messages in thread From: YuanZhe Liu @ 2026-10-29 8:48 UTC (permalink / raw) To: Jaroslav Kysela, Takashi Iwai Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable snd_usx2y_hwdep_dsp_load() sets up the asynchronous sequence URBs and the interrupt URB when the FPGA firmware image (index 1) is loaded. If a later step of the same request fails, for example the creation of the ALSA devices, a following DSP load request from user space enters the initialization functions for a second time. usx2y_async_seq04_init() and usx2y_in04_init() assert with WARN_ON() that they are called only once, so such a request triggers a kernel warning before returning -EBUSY, although nothing is corrupted: the functions bail out without allocating again and the leak that the check was added for is still prevented. Return -EBUSY without the warning. Fixes: 02d382af1c4e ("ALSA: usx2y: Fix potential memory leaks") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu <byu@xidian.edu.cn> Signed-off-by: Bin Yu <byu@xidian.edu.cn> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- sound/usb/usx2y/usbusx2y.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 108f9bddf9aa..14498ce84440 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -268,7 +268,7 @@ int usx2y_async_seq04_init(struct usx2ydev *usx2y) { int err = 0, i; - if (WARN_ON(usx2y->as04.buffer)) + if (usx2y->as04.buffer) return -EBUSY; usx2y->as04.buffer = kmalloc_array(URBS_ASYNC_SEQ, @@ -300,7 +300,7 @@ int usx2y_in04_init(struct usx2ydev *usx2y) { int err; - if (WARN_ON(usx2y->in04_urb)) + if (usx2y->in04_urb) return -EBUSY; usx2y->in04_urb = usb_alloc_urb(0, GFP_KERNEL); -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] ALSA: usx2y: Avoid WARN on a repeated DSP load 2026-10-29 8:48 ` [PATCH 2/2] ALSA: usx2y: Avoid WARN on a repeated DSP load YuanZhe Liu @ 2026-10-31 16:00 ` Takashi Iwai 2026-10-31 17:16 ` [PATCH v2] ALSA: usx2y: Release the URBs when the DSP load fails YuanZhe Liu ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Takashi Iwai @ 2026-10-31 16:00 UTC (permalink / raw) To: YuanZhe Liu Cc: Jaroslav Kysela, Takashi Iwai, Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable On Thu, 29 Oct 2026 09:48:10 +0100, YuanZhe Liu wrote: > > snd_usx2y_hwdep_dsp_load() sets up the asynchronous sequence URBs and > the interrupt URB when the FPGA firmware image (index 1) is loaded. If > a later step of the same request fails, for example the creation of the > ALSA devices, a following DSP load request from user space enters the > initialization functions for a second time. > > usx2y_async_seq04_init() and usx2y_in04_init() assert with WARN_ON() > that they are called only once, so such a request triggers a kernel > warning before returning -EBUSY, although nothing is corrupted: the > functions bail out without allocating again and the leak that the check > was added for is still prevented. > > Return -EBUSY without the warning. > > Fixes: 02d382af1c4e ("ALSA: usx2y: Fix potential memory leaks") > Cc: stable@vger.kernel.org > Co-developed-by: Bin Yu <byu@xidian.edu.cn> > Signed-off-by: Bin Yu <byu@xidian.edu.cn> > Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> > Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> > Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> IMO, it's better to fix the error path in snd_usx2y_hwdep_dsp_load() instead. The WARN_ON() was meant that it shouldn't happen, and if it happens, it's something to be fixed, instead. thanks, Takashi ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] ALSA: usx2y: Release the URBs when the DSP load fails 2026-10-31 16:00 ` Takashi Iwai @ 2026-10-31 17:16 ` YuanZhe Liu 2026-10-31 18:56 ` [PATCH v3] " YuanZhe Liu 2026-10-31 19:15 ` [PATCH v4] ALSA: usx2y: Refuse a retried DSP load after a failure YuanZhe Liu 2 siblings, 0 replies; 9+ messages in thread From: YuanZhe Liu @ 2026-10-31 17:16 UTC (permalink / raw) To: Jaroslav Kysela, Takashi Iwai Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable 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). Release the URBs on these error paths instead. A retried request then starts from a clean state and the assertions keep their meaning. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu <byu@xidian.edu.cn> Signed-off-by: Bin Yu <byu@xidian.edu.cn> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- v2: release the URBs on the failing paths of snd_usx2y_hwdep_dsp_load() instead of removing the WARN_ON()s, as suggested by Takashi Iwai. sound/usb/usx2y/usX2Yhwdep.c | 2 ++ sound/usb/usx2y/usbusx2y.c | 16 ++++++++++++++++ sound/usb/usx2y/usbusx2y.h | 1 + 3 files changed, 19 insertions(+) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 7f153a2fcdd8..13995e81d2ae 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -201,11 +201,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"); + usx2y_free_urbs(priv); return err; } err = usx2y_create_alsa_devices(hw->card); if (err) { dev_err(&dev->dev, "usx2y_create_alsa_devices error %i\n", err); + usx2y_free_urbs(priv); return err; } priv->chip_status |= USX2Y_STAT_CHIP_INIT; diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 108f9bddf9aa..8a551abe47dc 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -349,6 +349,22 @@ static void usx2y_unlinkseq(struct snd_usx2y_async_seq *s) s->buffer = NULL; } +/* + * Release the URBs set up by usx2y_async_seq04_init() and usx2y_in04_init(). + * Used when a later step of the DSP loading fails. + */ +void usx2y_free_urbs(struct usx2ydev *usx2y) +{ + if (usx2y->in04_urb) { + usb_kill_urb(usx2y->in04_urb); + usb_free_urb(usx2y->in04_urb); + usx2y->in04_urb = NULL; + kfree(usx2y->in04_buf); + usx2y->in04_buf = NULL; + } + usx2y_unlinkseq(&usx2y->as04); +} + static const struct usb_device_id snd_usx2y_usb_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_DEVICE, diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h index 7b6deed17d4b..e5e26ac8dc04 100644 --- a/sound/usb/usx2y/usbusx2y.h +++ b/sound/usb/usx2y/usbusx2y.h @@ -110,6 +110,7 @@ int usx2y_audio_create(struct snd_card *card); int usx2y_async_seq04_init(struct usx2ydev *usx2y); int usx2y_in04_init(struct usx2ydev *usx2y); +void usx2y_free_urbs(struct usx2ydev *usx2y); #define NAME_ALLCAPS "US-X2Y" -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] ALSA: usx2y: Release the URBs when the DSP load fails 2026-10-31 16:00 ` Takashi Iwai 2026-10-31 17:16 ` [PATCH v2] ALSA: usx2y: Release the URBs when the DSP load fails YuanZhe Liu @ 2026-10-31 18:56 ` YuanZhe Liu 2026-10-31 19:15 ` [PATCH v4] ALSA: usx2y: Refuse a retried DSP load after a failure YuanZhe Liu 2 siblings, 0 replies; 9+ messages in thread From: YuanZhe Liu @ 2026-10-31 18:56 UTC (permalink / raw) To: Jaroslav Kysela, Takashi Iwai Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable 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). Release the URBs on these error paths instead, so that a retried request starts from a clean state and the assertions keep their meaning. Releasing the URBs also lets a retried request reach usx2y_create_alsa_devices() again, on a card that keeps the MIDI and PCM devices created by the failed attempt. For the US-428 the audio streams would then index usx2y->subs[] past its end, so do not initialise a partially created card a second time: mark the chip as hung when the ALSA devices could not be created, and refuse further DSP load requests. A failure of usx2y_in04_init() leaves the card untouched and remains retryable. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu <byu@xidian.edu.cn> Signed-off-by: Bin Yu <byu@xidian.edu.cn> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- v3: do not initialise a partially created card a second time. A failed usx2y_create_alsa_devices() now marks the chip as hung, so a retried DSP load request returns -ENODEV instead of running the ALSA device creation again. sound/usb/usx2y/usX2Yhwdep.c | 6 ++++++ sound/usb/usx2y/usbusx2y.c | 16 ++++++++++++++++ sound/usb/usx2y/usbusx2y.h | 1 + 3 files changed, 23 insertions(+) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 7f153a2fcdd8..366167c62575 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -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,14 @@ 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"); + usx2y_free_urbs(priv); return err; } err = usx2y_create_alsa_devices(hw->card); if (err) { dev_err(&dev->dev, "usx2y_create_alsa_devices error %i\n", err); + usx2y_free_urbs(priv); + priv->chip_status |= USX2Y_STAT_CHIP_HUP; return err; } priv->chip_status |= USX2Y_STAT_CHIP_INIT; diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 108f9bddf9aa..8a551abe47dc 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -349,6 +349,22 @@ static void usx2y_unlinkseq(struct snd_usx2y_async_seq *s) s->buffer = NULL; } +/* + * Release the URBs set up by usx2y_async_seq04_init() and usx2y_in04_init(). + * Used when a later step of the DSP loading fails. + */ +void usx2y_free_urbs(struct usx2ydev *usx2y) +{ + if (usx2y->in04_urb) { + usb_kill_urb(usx2y->in04_urb); + usb_free_urb(usx2y->in04_urb); + usx2y->in04_urb = NULL; + kfree(usx2y->in04_buf); + usx2y->in04_buf = NULL; + } + usx2y_unlinkseq(&usx2y->as04); +} + static const struct usb_device_id snd_usx2y_usb_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_DEVICE, diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h index 7b6deed17d4b..e5e26ac8dc04 100644 --- a/sound/usb/usx2y/usbusx2y.h +++ b/sound/usb/usx2y/usbusx2y.h @@ -110,6 +110,7 @@ int usx2y_audio_create(struct snd_card *card); int usx2y_async_seq04_init(struct usx2ydev *usx2y); int usx2y_in04_init(struct usx2ydev *usx2y); +void usx2y_free_urbs(struct usx2ydev *usx2y); #define NAME_ALLCAPS "US-X2Y" -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4] ALSA: usx2y: Refuse a retried DSP load after a failure 2026-10-31 16:00 ` Takashi Iwai 2026-10-31 17:16 ` [PATCH v2] ALSA: usx2y: Release the URBs when the DSP load fails YuanZhe Liu 2026-10-31 18:56 ` [PATCH v3] " YuanZhe Liu @ 2026-10-31 19:15 ` YuanZhe Liu 2 siblings, 0 replies; 9+ messages in thread From: YuanZhe Liu @ 2026-10-31 19:15 UTC (permalink / raw) To: Jaroslav Kysela, Takashi Iwai Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable 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. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu <byu@xidian.edu.cn> Signed-off-by: Bin Yu <byu@xidian.edu.cn> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- v4: drop the release of the URBs on the error paths. The card may already have registered PCM devices, and the disconnect handler accesses the URBs without the DSP lock; mark the chip as hung instead and let snd_usx2y_card_private_free() release the URBs. sound/usb/usx2y/usX2Yhwdep.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 7f153a2fcdd8..3800c5b5887c 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -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; -- 2.34.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load 2026-10-29 8:48 [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu 2026-10-29 8:48 ` [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu 2026-10-29 8:48 ` [PATCH 2/2] ALSA: usx2y: Avoid WARN on a repeated DSP load YuanZhe Liu @ 2026-10-30 17:36 ` YuanZhe Liu 2 siblings, 0 replies; 9+ messages in thread From: YuanZhe Liu @ 2026-10-30 17:36 UTC (permalink / raw) To: Jaroslav Kysela, Takashi Iwai, Takashi Iwai Cc: Bin Yu, Cheng Wen, linux-sound, linux-kernel, stable Hi Takashi, Could you please review this patch series? [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load It serializes concurrent hwdep DSP load requests and returns EBUSY instead of triggering a WARN on repeated usx2y initialization. The series is unchanged. I am copying this address for visibility. Original submission: https://lore.kernel.org/r/20261029084810.21910-1-25031212351@stu.xidian.edu.cn Thanks, YuanZhe ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-10-31 19:16 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-10-29 8:48 [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu 2026-10-29 8:48 ` [PATCH 1/2] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu 2026-10-31 16:00 ` Takashi Iwai 2026-10-29 8:48 ` [PATCH 2/2] ALSA: usx2y: Avoid WARN on a repeated DSP load YuanZhe Liu 2026-10-31 16:00 ` Takashi Iwai 2026-10-31 17:16 ` [PATCH v2] ALSA: usx2y: Release the URBs when the DSP load fails YuanZhe Liu 2026-10-31 18:56 ` [PATCH v3] " YuanZhe Liu 2026-10-31 19:15 ` [PATCH v4] ALSA: usx2y: Refuse a retried DSP load after a failure YuanZhe Liu 2026-10-30 17:36 ` [PATCH 0/2] ALSA: fix a user-triggerable WARN on repeated DSP load YuanZhe Liu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®