[PATCH 1/6] ALSA: control: Return -ENODEV instead of -EFAULT in snd_ctl_open()
From: phucduc . bui
Date: Mon Jul 06 2026 - 05:00:28 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
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@xxxxxxxxx>
---
sound/core/control.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/core/control.c b/sound/core/control.c
index 037e455bb11b..f64b2dec746a 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -64,11 +64,10 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
}
err = snd_card_file_add(card, file);
if (err < 0) {
- err = -ENODEV;
goto __error1;
}
if (!try_module_get(card->module)) {
- err = -EFAULT;
+ err = -ENODEV;
goto __error2;
}
ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
--
2.43.0