[PATCH] sound: Remove redundant steps

Takashi Iwai tiwai at suse.de
Wed Mar 10 10:09:04 CET 2021


On Wed, 10 Mar 2021 07:34:26 +0100,
zuoqilin1 at 163.com wrote:
> 
> From: zuoqilin <zuoqilin at yulong.com>
> 
> If kzalloc fail,not need free it,so just return
> -ENOMEM when kzalloc fail.

No, this check is performed after two kzalloc calls, so one might
remain if you return immediately there.


thanks,

Takashi

> 
> Signed-off-by: zuoqilin <zuoqilin at yulong.com>
> ---
>  sound/core/oss/mixer_oss.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
> index bec9283..eec61dc 100644
> --- a/sound/core/oss/mixer_oss.c
> +++ b/sound/core/oss/mixer_oss.c
> @@ -800,8 +800,7 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
>  	uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
>  	uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
>  	if (uinfo == NULL || uctl == NULL) {
> -		err = -ENOMEM;
> -		goto __free_only;
> +		return -ENOMEM;
>  	}
>  	down_read(&card->controls_rwsem);
>  	kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
> @@ -851,8 +850,7 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
>  	uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
>  	uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
>  	if (uinfo == NULL || uctl == NULL) {
> -		err = -ENOMEM;
> -		goto __free_only;
> +		return -ENOMEM;
>  	}
>  	down_read(&card->controls_rwsem);
>  	kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
> -- 
> 1.9.1
> 
> 


More information about the Alsa-devel mailing list