ALSA: pcm: Return -ENODEV instead of -EFAULT in snd_pcm_open()

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>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260707084506.718583-7-phucduc.bui@gmail.com
This commit is contained in:
bui duc phuc 2026-07-07 15:45:06 +07:00 committed by Takashi Iwai
parent d9468d5286
commit a0a47b0ae2

View File

@ -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);