* FAILED: patch "[PATCH] ALSA: hwdep: Serialize DSP load requests" failed to apply to 5.10-stable tree
@ 2026-11-10 1:25 Sasha Levin
2026-11-11 4:18 ` [PATCH 5.10.y] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu
0 siblings, 1 reply; 5+ messages in thread
From: Sasha Levin @ 2026-11-10 1:25 UTC (permalink / raw)
To: 25031212351, byu, wencheng, tiwai; +Cc: stable
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 <stable@vger.kernel.org>.
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 aee83c204f80d56b4d55f53acdb8594308ddcd4a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '20261109202559-failed-5.10-aee83c204f80@kernel.org' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From aee83c204f80d56b4d55f53acdb8594308ddcd4a Mon Sep 17 00:00:00 2001
From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Date: Thu, 29 Oct 2026 16:48:09 +0800
Subject: [PATCH] ALSA: hwdep: Serialize DSP load requests
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>
Link: https://patch.msgid.link/20261029084810.21910-2-25031212351@stu.xidian.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
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 b0da633184cde..7357727f06603 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 c6de5345e946f..fb9034897c561 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.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 5.10.y] ALSA: hwdep: Serialize DSP load requests
2026-11-10 1:25 FAILED: patch "[PATCH] ALSA: hwdep: Serialize DSP load requests" failed to apply to 5.10-stable tree Sasha Levin
@ 2026-11-11 4:18 ` YuanZhe Liu
2026-11-11 21:54 ` Sasha Levin
0 siblings, 1 reply; 5+ messages in thread
From: YuanZhe Liu @ 2026-11-11 4:18 UTC (permalink / raw)
To: 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>
Link: https://patch.msgid.link/20261029084810.21910-2-25031212351@stu.xidian.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit aee83c204f80d56b4d55f53acdb8594308ddcd4a)
---
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 8d6cdb254..137be4b40 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 0c0298928..dea86d223 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -211,6 +211,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;
@@ -376,6 +377,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 related [flat|nested] 5+ messages in thread* Re: [PATCH 5.10.y] ALSA: hwdep: Serialize DSP load requests
2026-11-11 4:18 ` [PATCH 5.10.y] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu
@ 2026-11-11 21:54 ` Sasha Levin
2026-11-12 1:39 ` [PATCH 5.10.y v2] " YuanZhe Liu
2026-11-12 1:39 ` [PATCH 5.15.y " YuanZhe Liu
0 siblings, 2 replies; 5+ messages in thread
From: Sasha Levin @ 2026-11-11 21:54 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin, YuanZhe Liu
> [PATCH 5.10.y] ALSA: hwdep: Serialize DSP load requests
guard(mutex)(&hw->dsp_mutex) sits after two early returns in
snd_hwdep_dsp_load(). 5.15 and 5.10 build with -std=gnu89
-Wdeclaration-after-statement, so this fails the 5.15 build with
CONFIG_WERROR=y ("ISO C90 forbids mixed declarations and code") and warns on
5.10.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 5.10.y v2] ALSA: hwdep: Serialize DSP load requests
2026-11-11 21:54 ` Sasha Levin
@ 2026-11-12 1:39 ` YuanZhe Liu
2026-11-12 1:39 ` [PATCH 5.15.y " YuanZhe Liu
1 sibling, 0 replies; 5+ messages in thread
From: YuanZhe Liu @ 2026-11-12 1:39 UTC (permalink / raw)
To: 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.
5.10 and 5.15 still build with -std=gnu89, so guard() cannot be used
after the early returns of this function. Take the mutex explicitly
and release it on every exit path instead.
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>
Link: https://patch.msgid.link/20261029084810.21910-2-25031212351@stu.xidian.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit aee83c204f80d56b4d55f53acdb8594308ddcd4a)
---
include/sound/hwdep.h | 1 +
sound/core/hwdep.c | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h
index 8d6cdb254..137be4b40 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 0c0298928..2862cbe75 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -211,14 +211,19 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
return -ENXIO;
if (info->index >= 32)
return -EINVAL;
+ mutex_lock(&hw->dsp_mutex);
/* check whether the dsp was already loaded */
- if (hw->dsp_loaded & (1u << info->index))
- return -EBUSY;
+ if (hw->dsp_loaded & (1u << info->index)) {
+ err = -EBUSY;
+ goto unlock;
+ }
err = hw->ops.dsp_load(hw, info);
if (err < 0)
- return err;
+ goto unlock;
hw->dsp_loaded |= (1u << info->index);
- return 0;
+unlock:
+ mutex_unlock(&hw->dsp_mutex);
+ return err;
}
static int snd_hwdep_dsp_load_user(struct snd_hwdep *hw,
@@ -376,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 related [flat|nested] 5+ messages in thread* [PATCH 5.15.y v2] ALSA: hwdep: Serialize DSP load requests
2026-11-11 21:54 ` Sasha Levin
2026-11-12 1:39 ` [PATCH 5.10.y v2] " YuanZhe Liu
@ 2026-11-12 1:39 ` YuanZhe Liu
1 sibling, 0 replies; 5+ messages in thread
From: YuanZhe Liu @ 2026-11-12 1:39 UTC (permalink / raw)
To: 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.
5.10 and 5.15 still build with -std=gnu89, so guard() cannot be used
after the early returns of this function. Take the mutex explicitly
and release it on every exit path instead.
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>
Link: https://patch.msgid.link/20261029084810.21910-2-25031212351@stu.xidian.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit aee83c204f80d56b4d55f53acdb8594308ddcd4a)
---
include/sound/hwdep.h | 1 +
sound/core/hwdep.c | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h
index 8d6cdb254..137be4b40 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 e95fa275c..f7cde6bb8 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -212,14 +212,19 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
return -ENXIO;
if (info->index >= 32)
return -EINVAL;
+ mutex_lock(&hw->dsp_mutex);
/* check whether the dsp was already loaded */
- if (hw->dsp_loaded & (1u << info->index))
- return -EBUSY;
+ if (hw->dsp_loaded & (1u << info->index)) {
+ err = -EBUSY;
+ goto unlock;
+ }
err = hw->ops.dsp_load(hw, info);
if (err < 0)
- return err;
+ goto unlock;
hw->dsp_loaded |= (1u << info->index);
- return 0;
+unlock:
+ mutex_unlock(&hw->dsp_mutex);
+ return err;
}
static int snd_hwdep_dsp_load_user(struct snd_hwdep *hw,
@@ -377,6 +382,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 related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-12 1:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 1:25 FAILED: patch "[PATCH] ALSA: hwdep: Serialize DSP load requests" failed to apply to 5.10-stable tree Sasha Levin
2026-11-11 4:18 ` [PATCH 5.10.y] ALSA: hwdep: Serialize DSP load requests YuanZhe Liu
2026-11-11 21:54 ` Sasha Levin
2026-11-12 1:39 ` [PATCH 5.10.y v2] " YuanZhe Liu
2026-11-12 1:39 ` [PATCH 5.15.y " YuanZhe Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox