diff mbox series

sound: Remove redundant steps

Message ID 20210310063426.524-1-zuoqilin1@163.com
State New
Headers show
Series sound: Remove redundant steps | expand

Commit Message

zuoqilin1@163.com March 10, 2021, 6:34 a.m. UTC
From: zuoqilin <zuoqilin@yulong.com>

If kzalloc fail,not need free it,so just return
-ENOMEM when kzalloc fail.

Signed-off-by: zuoqilin <zuoqilin@yulong.com>
---
 sound/core/oss/mixer_oss.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Takashi Iwai March 10, 2021, 9:09 a.m. UTC | #1
On Wed, 10 Mar 2021 07:34:26 +0100,
zuoqilin1@163.com wrote:
> 
> From: zuoqilin <zuoqilin@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@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
> 
>
diff mbox series

Patch

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);