ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
PATCH 1/1 ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
From: bui duc phuc <[email protected]>
snd_ctl_open() unconditionally overwrites the return value of snd_card_file_add() with -ENODEV on failure, discarding the actual error code.
This also preserves the original error code returned by snd_card_file_add() (e.g. -ENOMEM or -ENODEV), instead of unconditionally overwriting it with -ENODEV.
No functional change other than the returned error code in this failure path.
--- sound/core/control.c | 1 - 1 file changed, 1 deletion(-)
sound/core/control.c +0 -1
@@ -64,7 +64,6 @@ 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)) {
Signature · 1 line
2.43.0
Quoted 22 lines · On Tue, 07 Jul 2026 11:09:58 +0200, [email protected] wrote:
From: bui duc phuc <[email protected]>
snd_ctl_open()unconditionally overwrites the return value ofsnd_card_file_add()with-ENODEVon failure, discarding the actual error code.
This also preserves the original error code returned bysnd_card_file_add()(e.g.-ENOMEMor-ENODEV), instead of unconditionally overwriting it with-ENODEV.
No functional change other than the returned error code in this failure path.Signed-off-by bui duc phuc <[email protected]>--- sound/core/control.c | 1 - 1 file changed, 1 deletion(-)sound/core/control.c +0
-0
sound/core/control.c static int snd_ctl_open(struct inode *inode, struct file *file) · line 68
Quoted 6 lines
sound/core/control.c +0
-1@@ -64,7 +64,6 @@ 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; }
Please drop superfluous braces, too, as it becomes a single-line now.
thanks,
Takashi
Hi Takashi-san,
Thank you for your review!
Quoted 7 lines
Quoted 4 lines
if (err < 0) { - err = -ENODEV; goto __error1; }Please drop superfluous braces, too, as it becomes a single-line now.
I'll update the patch according to your comments.
I'll also expand the commit message to mention that returning the error directly from snd_card_file_add()
is consistent with the error handling used in functions such as snd_mixer_oss_open(), snd_hwdep_open(), snd_pcm_oss_open(), and others.
I'd also like to add one more observation. It seems that checkpatch.pl did not detect the style issue that
you pointed out:
------------------------
phuc@phuc-desktop:~/work/linux$ ./scripts/checkpatch.pl --strict 0001-ALSA-control-preserve-snd_card_file_add-error-code-i.patch total: 0 errors, 0 warnings, 0 checks, 7 lines checked
0001-ALSA-control-preserve-snd_card_file_add-error-code-i.patch has no obvious style problems and is ready for submission. phuc@phuc-desktop:~/work/linux$
-------------------------
Best regards,
Phuc