* [PATCH v2 1/6] ALSA: control: Return -ENODEV instead of -EFAULT in snd_ctl_open()
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
@ 2026-07-07 8:45 ` phucduc.bui
2026-07-07 8:45 ` [PATCH v2 2/6] ALSA: hwdep: Return -ENODEV instead of -EFAULT in snd_hwdep_open() phucduc.bui
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: phucduc.bui @ 2026-07-07 8:45 UTC (permalink / raw)
To: Cezary Rojewski, Jaroslav Kysela, Takashi Iwai,
cassiogabrielcontato
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
When try_module_get() fails in snd_ctl_open(), the owning module is going
away and the device is no longer usable, so -EFAULT ("bad address") is the
wrong error. Return -ENODEV, matching the other unavailable-device paths
in this function(the NULL card check and the snd_card_file_add() failure).
This changes the errno reported to userspace on this rare race.
No other behaviour changes.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
Changes in v2:
- Drop the unrelated change from this series.
sound/core/control.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/control.c b/sound/core/control.c
index 037e455bb11b..0ca9fff56e51 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -68,7 +68,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
goto __error1;
}
if (!try_module_get(card->module)) {
- err = -EFAULT;
+ err = -ENODEV;
goto __error2;
}
ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 2/6] ALSA: hwdep: Return -ENODEV instead of -EFAULT in snd_hwdep_open()
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
2026-07-07 8:45 ` [PATCH v2 1/6] ALSA: control: Return -ENODEV instead of -EFAULT in snd_ctl_open() phucduc.bui
@ 2026-07-07 8:45 ` phucduc.bui
2026-07-07 8:45 ` [PATCH v2 3/6] ALSA: info: Return -ENODEV instead of -EFAULT in alloc_info_private() phucduc.bui
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: phucduc.bui @ 2026-07-07 8:45 UTC (permalink / raw)
To: Cezary Rojewski, Jaroslav Kysela, Takashi Iwai,
cassiogabrielcontato
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
When try_module_get() fails in snd_hwdep_open(), the owning module is
going away and the device is no longer usable, so -EFAULT ("bad address")
is the wrong error. Return -ENODEV, matching the other unavailable-device
paths in this function(the NULL hw check and the card->shutdown check).
This changes the errno reported to userspace on this rare race.
No other behaviour changes.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/core/hwdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 973d11732bfd..352047e0b33e 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -87,7 +87,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
if (!try_module_get(hw->card->module)) {
snd_card_unref(hw->card);
- return -EFAULT;
+ return -ENODEV;
}
init_waitqueue_entry(&wait, current);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 3/6] ALSA: info: Return -ENODEV instead of -EFAULT in alloc_info_private()
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
2026-07-07 8:45 ` [PATCH v2 1/6] ALSA: control: Return -ENODEV instead of -EFAULT in snd_ctl_open() phucduc.bui
2026-07-07 8:45 ` [PATCH v2 2/6] ALSA: hwdep: Return -ENODEV instead of -EFAULT in snd_hwdep_open() phucduc.bui
@ 2026-07-07 8:45 ` phucduc.bui
2026-07-07 8:45 ` [PATCH v2 4/6] ALSA: mixer: oss: Return -ENODEV instead of -EFAULT in snd_mixer_oss_open() phucduc.bui
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: phucduc.bui @ 2026-07-07 8:45 UTC (permalink / raw)
To: Cezary Rojewski, Jaroslav Kysela, Takashi Iwai,
cassiogabrielcontato
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
When try_module_get() fails in alloc_info_private(), the owning module is
going away and the device is no longer usable, so -EFAULT ("bad address")
is the wrong error. Return -ENODEV, matching the other -ENODEV path in the
same function.
This changes the errno reported to userspace on this rare race.
No other behaviour changes.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/core/info.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/info.c b/sound/core/info.c
index 54834dbe6b59..3b8ccda04e1a 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -78,7 +78,7 @@ static int alloc_info_private(struct snd_info_entry *entry,
if (!entry || !entry->p)
return -ENODEV;
if (!try_module_get(entry->module))
- return -EFAULT;
+ return -ENODEV;
data = kzalloc_obj(*data);
if (!data) {
module_put(entry->module);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 4/6] ALSA: mixer: oss: Return -ENODEV instead of -EFAULT in snd_mixer_oss_open()
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
` (2 preceding siblings ...)
2026-07-07 8:45 ` [PATCH v2 3/6] ALSA: info: Return -ENODEV instead of -EFAULT in alloc_info_private() phucduc.bui
@ 2026-07-07 8:45 ` phucduc.bui
2026-07-07 8:45 ` [PATCH v2 5/6] ALSA: pcm: oss: Return -ENODEV instead of -EFAULT in snd_pcm_oss_open() phucduc.bui
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: phucduc.bui @ 2026-07-07 8:45 UTC (permalink / raw)
To: Cezary Rojewski, Jaroslav Kysela, Takashi Iwai,
cassiogabrielcontato
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
When try_module_get() fails in snd_mixer_oss_open(), the owning module is
going away and the device is no longer usable, so -EFAULT ("bad address")
is the wrong error. Return -ENODEV, matching the other unavailable-device
paths in this function(the NULL card check and the NULL mixer_oss check).
This changes the errno reported to userspace on this rare race.
No other behaviour changes.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/core/oss/mixer_oss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index f5bcc7896542..3a1dd1edd26d 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -58,7 +58,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
kfree(fmixer);
snd_card_file_remove(card, file);
snd_card_unref(card);
- return -EFAULT;
+ return -ENODEV;
}
snd_card_unref(card);
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 5/6] ALSA: pcm: oss: Return -ENODEV instead of -EFAULT in snd_pcm_oss_open()
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
` (3 preceding siblings ...)
2026-07-07 8:45 ` [PATCH v2 4/6] ALSA: mixer: oss: Return -ENODEV instead of -EFAULT in snd_mixer_oss_open() phucduc.bui
@ 2026-07-07 8:45 ` phucduc.bui
2026-07-07 8:45 ` [PATCH v2 6/6] ALSA: pcm: Return -ENODEV instead of -EFAULT in snd_pcm_open() phucduc.bui
2026-07-07 9:30 ` [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure Cezary Rojewski
6 siblings, 0 replies; 8+ messages in thread
From: phucduc.bui @ 2026-07-07 8:45 UTC (permalink / raw)
To: Cezary Rojewski, Jaroslav Kysela, Takashi Iwai,
cassiogabrielcontato
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
When try_module_get() fails in snd_pcm_oss_open(), the owning module is
going away and the device is no longer usable, so -EFAULT ("bad address")
is the wrong error. Return -ENODEV, matching the other unavailable-device
paths in this function(the NULL pcm check and the card->shutdown check).
This changes the errno reported to userspace on this rare race.
No other behaviour changes.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/core/oss/pcm_oss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 0d7818eb3e14..8ae43755fb9b 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2507,7 +2507,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
if (err < 0)
goto __error1;
if (!try_module_get(pcm->card->module)) {
- err = -EFAULT;
+ err = -ENODEV;
goto __error2;
}
if (snd_task_name(current, task_name, sizeof(task_name)) < 0) {
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 6/6] ALSA: pcm: Return -ENODEV instead of -EFAULT in snd_pcm_open()
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
` (4 preceding siblings ...)
2026-07-07 8:45 ` [PATCH v2 5/6] ALSA: pcm: oss: Return -ENODEV instead of -EFAULT in snd_pcm_oss_open() phucduc.bui
@ 2026-07-07 8:45 ` phucduc.bui
2026-07-07 9:30 ` [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure Cezary Rojewski
6 siblings, 0 replies; 8+ messages in thread
From: phucduc.bui @ 2026-07-07 8:45 UTC (permalink / raw)
To: Cezary Rojewski, Jaroslav Kysela, Takashi Iwai,
cassiogabrielcontato
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
When try_module_get() fails in snd_pcm_open(), the owning module is going
away and the device is no longer usable, so -EFAULT ("bad address") is the
wrong error. Return -ENODEV, matching the other unavailable-device paths
in this function(the NULL pcm check and the card->shutdown check).
This changes the errno reported to userspace on this rare race.
No other behaviour changes.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/core/pcm_native.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 3462cd5275a2..4fe5fab8d096 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2913,7 +2913,7 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
if (err < 0)
goto __error1;
if (!try_module_get(pcm->card->module)) {
- err = -EFAULT;
+ err = -ENODEV;
goto __error2;
}
init_waitqueue_entry(&wait, current);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure
2026-07-07 8:45 [PATCH v2 0/6] ALSA: Return -ENODEV instead of -EFAULT on module-get failure phucduc.bui
` (5 preceding siblings ...)
2026-07-07 8:45 ` [PATCH v2 6/6] ALSA: pcm: Return -ENODEV instead of -EFAULT in snd_pcm_open() phucduc.bui
@ 2026-07-07 9:30 ` Cezary Rojewski
6 siblings, 0 replies; 8+ messages in thread
From: Cezary Rojewski @ 2026-07-07 9:30 UTC (permalink / raw)
To: phucduc.bui
Cc: Kees Cook, Dan Carpenter, Cen Zhang, Len Bao, Mehul Rao,
Sebastian Andrzej Siewior, linux-sound, linux-kernel,
Jaroslav Kysela, Takashi Iwai, cassiogabrielcontato
On 7/7/2026 10:45 AM, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> Hi all,
>
> Several ALSA open/allocate paths call try_module_get() on the owning card
> module and return -EFAULT when it fails. However, try_module_get() fails
> when the module is no longer live (i.e. it is going away), meaning the
> device is no longer usable.
> This series updates only those paths, making the error code consistent
> with the existing "device unavailable" checks in the same functions.
> Other -EFAULT returns are left unchanged.
>
> Link v1:
> https://lore.kernel.org/all/20260706084950.49331-1-phucduc.bui@gmail.com/
>
> Changes in v2:
> - Update the commit message.
> - Remove unrelated changes from the "ALSA: control: Return -ENODEV
> instead of -EFAULT in snd_ctl_open()" patch.
For the series:
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread