The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
@ 2026-07-08  2:35 phucduc.bui
  2026-07-08  6:53 ` Cezary Rojewski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: phucduc.bui @ 2026-07-08  2:35 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.

Fix this by directly returning the original error code returned by
snd_card_file_add() (e.g. -ENOMEM or -ENODEV). This behavior is
consistent with the error handling used in other functions such as
snd_mixer_oss_open(), snd_hwdep_open(), snd_pcm_oss_open(), and others.

There is no functional change other than the returned error code in this
failure path.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---

Changes in v2: 
 - Update commit messages.
 - Drop superfluous braces.

 sound/core/control.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index 0ca9fff56e51..73d7ba0f509f 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -63,10 +63,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
 		goto __error1;
 	}
 	err = snd_card_file_add(card, file);
-	if (err < 0) {
-		err = -ENODEV;
+	if (err < 0)
 		goto __error1;
-	}
 	if (!try_module_get(card->module)) {
 		err = -ENODEV;
 		goto __error2;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
  2026-07-08  2:35 [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open() phucduc.bui
@ 2026-07-08  6:53 ` Cezary Rojewski
  2026-07-08 10:49 ` Takashi Iwai
  2026-07-08 11:02 ` Cezary Rojewski
  2 siblings, 0 replies; 5+ messages in thread
From: Cezary Rojewski @ 2026-07-08  6:53 UTC (permalink / raw)
  To: phucduc.bui
  Cc: cassiogabrielcontato, Mark Brown, Kees Cook, linux-sound,
	linux-kernel, Jaroslav Kysela, Takashi Iwai

On 7/8/2026 4:35 AM, 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.
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
  2026-07-08  2:35 [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open() phucduc.bui
  2026-07-08  6:53 ` Cezary Rojewski
@ 2026-07-08 10:49 ` Takashi Iwai
  2026-07-08 11:02 ` Cezary Rojewski
  2 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2026-07-08 10:49 UTC (permalink / raw)
  To: phucduc.bui
  Cc: Jaroslav Kysela, Takashi Iwai, cassiogabrielcontato,
	Cezary Rojewski, Mark Brown, Kees Cook, linux-sound, linux-kernel

On Wed, 08 Jul 2026 04:35:40 +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.
> 
> Fix this by directly returning the original error code returned by
> snd_card_file_add() (e.g. -ENOMEM or -ENODEV). This behavior is
> consistent with the error handling used in other functions such as
> snd_mixer_oss_open(), snd_hwdep_open(), snd_pcm_oss_open(), and others.
> 
> There is no functional change other than the returned error code in this
> failure path.
> 
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>

Applied now to for-next branch.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
  2026-07-08  2:35 [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open() phucduc.bui
  2026-07-08  6:53 ` Cezary Rojewski
  2026-07-08 10:49 ` Takashi Iwai
@ 2026-07-08 11:02 ` Cezary Rojewski
  2026-07-08 13:10   ` Bui Duc Phuc
  2 siblings, 1 reply; 5+ messages in thread
From: Cezary Rojewski @ 2026-07-08 11:02 UTC (permalink / raw)
  To: phucduc.bui
  Cc: cassiogabrielcontato, Mark Brown, Kees Cook, linux-sound,
	linux-kernel, Jaroslav Kysela, Takashi Iwai

On 7/8/2026 4:35 AM, 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.
> 
> Fix this by directly returning the original error code returned by
> snd_card_file_add() (e.g. -ENOMEM or -ENODEV). This behavior is
> consistent with the error handling used in other functions such as
> snd_mixer_oss_open(), snd_hwdep_open(), snd_pcm_oss_open(), and others.
> 
> There is no functional change other than the returned error code in this
> failure path.

BTW, as you've provided a number of positive contributions, a tip for 
future:

The change is simple and does not relate to any workaround or some kind 
of 'recommended' sequence.  And thus there's no need to be as verbose. 
IMHO the first paragraph suffices - explicitly answers the _why_ question.

The last is completely redundant - return code is a functional change. 
Similarly, "Fix this by (...)" in context of such a simple change yields 
no value for the reader - we see _what_ is happening clearly in the code.
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
> ---
> 
> Changes in v2:
>   - Update commit messages.
>   - Drop superfluous braces.
> 
>   sound/core/control.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/sound/core/control.c b/sound/core/control.c
> index 0ca9fff56e51..73d7ba0f509f 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -63,10 +63,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
>   		goto __error1;
>   	}
>   	err = snd_card_file_add(card, file);
> -	if (err < 0) {
> -		err = -ENODEV;
> +	if (err < 0)
>   		goto __error1;
> -	}
>   	if (!try_module_get(card->module)) {
>   		err = -ENODEV;
>   		goto __error2;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open()
  2026-07-08 11:02 ` Cezary Rojewski
@ 2026-07-08 13:10   ` Bui Duc Phuc
  0 siblings, 0 replies; 5+ messages in thread
From: Bui Duc Phuc @ 2026-07-08 13:10 UTC (permalink / raw)
  To: Cezary Rojewski
  Cc: cassiogabrielcontato, Mark Brown, Kees Cook, linux-sound,
	linux-kernel, Jaroslav Kysela, Takashi Iwai

Hi Cezary,

Thanks for the tip, appreciate it.

> BTW, as you've provided a number of positive contributions, a tip for
> future:
>
> The change is simple and does not relate to any workaround or some kind
> of 'recommended' sequence.  And thus there's no need to be as verbose.
> IMHO the first paragraph suffices - explicitly answers the _why_ question.
>
> The last is completely redundant - return code is a functional change.
> Similarly, "Fix this by (...)" in context of such a simple change yields
> no value for the reader - we see _what_ is happening clearly in the code.

Will keep future commit messages more concise and focused on the why.

Best regards,
Phuc

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-08 13:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08  2:35 [PATCH v2] ALSA: control: preserve snd_card_file_add() error code in snd_ctl_open() phucduc.bui
2026-07-08  6:53 ` Cezary Rojewski
2026-07-08 10:49 ` Takashi Iwai
2026-07-08 11:02 ` Cezary Rojewski
2026-07-08 13:10   ` 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