[PATCH 2/6] ALSA: hwdep: Return -ENODEV instead of -EFAULT in snd_hwdep_open()

From: phucduc . bui

Date: Mon Jul 06 2026 - 05:19:27 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

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@xxxxxxxxx>
---
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