[PATCH 33/69] ALSA: gus: properly handle snd_ctl_add() error

From: Greg Kroah-Hartman
Date: Mon May 03 2021 - 08:00:31 EST


From: Kurt Manucredo <fuzzybritches0@xxxxxxxxx>

snd_gus_init_control() does not properly return any possible error that
might have happened in a call to snd_ctl_add() so resolve this by
propagating the error back up the call change correctly.

Cc: Takashi Iwai <tiwai@xxxxxxx>
Signed-off-by: Kurt Manucredo <fuzzybritches0@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
sound/isa/gus/gus_main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index b7518122a10d..4c2703ea55fb 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -75,10 +75,11 @@ static const struct snd_kcontrol_new snd_gus_joystick_control = {
.put = snd_gus_joystick_put
};

-static void snd_gus_init_control(struct snd_gus_card *gus)
+static int snd_gus_init_control(struct snd_gus_card *gus)
{
if (!gus->ace_flag)
- snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus));
+ return snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus));
+ return 0;
}

/*
@@ -386,8 +387,7 @@ static int snd_gus_check_version(struct snd_gus_card * gus)
}
strcpy(card->shortname, card->longname);
gus->uart_enable = 1; /* standard GUSes doesn't have midi uart trouble */
- snd_gus_init_control(gus);
- return 0;
+ return snd_gus_init_control(gus);
}

int snd_gus_initialize(struct snd_gus_card *gus)
--
2.31.1