* [PATCH] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
@ 2026-07-07 9:09 phucduc.bui
2026-07-07 14:43 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: phucduc.bui @ 2026-07-07 9:09 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: cassiogabrielcontato, Cezary Rojewski, Mark Brown, Kees Cook,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
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.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/core/control.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/sound/core/control.c b/sound/core/control.c
index 0ca9fff56e51..f64b2dec746a 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -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)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
2026-07-07 9:09 [PATCH] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open() phucduc.bui
@ 2026-07-07 14:43 ` Takashi Iwai
2026-07-08 2:17 ` Bui Duc Phuc
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2026-07-07 14:43 UTC (permalink / raw)
To: phucduc.bui
Cc: Jaroslav Kysela, Takashi Iwai, cassiogabrielcontato,
Cezary Rojewski, Mark Brown, Kees Cook, linux-sound, linux-kernel
On Tue, 07 Jul 2026 11:09:58 +0200,
phucduc.bui@gmail.com wrote:
>
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> 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.
>
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
> ---
> sound/core/control.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/sound/core/control.c b/sound/core/control.c
> index 0ca9fff56e51..f64b2dec746a 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
2026-07-07 14:43 ` Takashi Iwai
@ 2026-07-08 2:17 ` Bui Duc Phuc
0 siblings, 0 replies; 3+ messages in thread
From: Bui Duc Phuc @ 2026-07-08 2:17 UTC (permalink / raw)
To: Takashi Iwai
Cc: Jaroslav Kysela, Takashi Iwai, cassiogabrielcontato,
Cezary Rojewski, Mark Brown, Kees Cook, linux-sound, linux-kernel
Hi Takashi-san,
Thank you for your review!
> > 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-08 2:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 9:09 [PATCH] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open() phucduc.bui
2026-07-07 14:43 ` Takashi Iwai
2026-07-08 2:17 ` Bui Duc Phuc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox