lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <874ir7h3vm.wl-tiwai@suse.de>
Date: Thu, 06 Nov 2025 11:06:21 +0100
From: Takashi Iwai <tiwai@...e.de>
To: wangdich9700@....com
Cc: lgirdwood@...il.com,
	broonie@...nel.org,
	perex@...ex.cz,
	tiwai@...e.com,
	linux-kernel@...r.kernel.org,
	linux-sound@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	wangdicheng <wangdicheng@...inos.cn>
Subject: Re: [PATCH] ALSA: hda/senary: Fix potential resource leak in set_beep_amp

On Thu, 06 Nov 2025 07:35:46 +0100,
wangdich9700@....com wrote:
> 
> From: wangdicheng <wangdich9700@....com>
> 
> Add proper error handling in set_beep_amp function to avoid potential
> resource leaks when snd_hda_gen_add_kctl fails.
> 
> Signed-off-by: wangdicheng <wangdicheng@...inos.cn>

Please align both From and Signed-off-by addresses.
And in this patch...

> ---
>  sound/hda/codecs/senarytech.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/hda/codecs/senarytech.c b/sound/hda/codecs/senarytech.c
> index 9aa1e9bcd9ec..99af8d5e51db 100644
> --- a/sound/hda/codecs/senarytech.c
> +++ b/sound/hda/codecs/senarytech.c
> @@ -47,17 +47,28 @@ static int set_beep_amp(struct senary_spec *spec, hda_nid_t nid,
>  {
>  	struct snd_kcontrol_new *knew;
>  	unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
> -	int i;
> +	int i, err;
>  
>  	spec->gen.beep_nid = nid;
>  	for (i = 0; i < ARRAY_SIZE(senary_beep_mixer); i++) {
>  		knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
>  					    &senary_beep_mixer[i]);
> -		if (!knew)
> -			return -ENOMEM;
> +		if (!knew) {
> +			err = -ENOMEM;
> +			goto error;
> +		}
>  		knew->private_value = beep_amp;
>  	}
>  	return 0;
> +
> +error:
> +	/* Clean up any successfully added controls */
> +	while (i-- > 0) {
> +		/* The gen spec will be cleaned up in senary_remove,
> +		 * so we don't need individual cleanup here
> +		 */
> +	}
> +	return err;
>  }

So the "error handling" you added is just an empty loop.
What really does this patch "fix"?
As of this, it looks like just adding some garbage.


thanks,

Takashi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ