[PATCH] ALSA: sh: Use more common error handling code in snd_aica_probe()

From: Markus Elfring

Date: Wed Jun 17 2026 - 02:58:34 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Jun 2026 08:42:18 +0200

Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
sound/sh/aica.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 9438c3a68ee9..8196e1bf0416 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -564,10 +564,9 @@ static int snd_aica_probe(struct platform_device *devptr)
return -ENOMEM;
err = snd_card_new(&devptr->dev, index, SND_AICA_DRIVER,
THIS_MODULE, 0, &dreamcastcard->card);
- if (unlikely(err < 0)) {
- kfree(dreamcastcard);
- return err;
- }
+ if (unlikely(err < 0))
+ goto free_card;
+
strscpy(dreamcastcard->card->driver, "snd_aica");
strscpy(dreamcastcard->card->shortname, SND_AICA_DRIVER);
strscpy(dreamcastcard->card->longname,
@@ -593,6 +592,7 @@ static int snd_aica_probe(struct platform_device *devptr)
return 0;
freedreamcast:
snd_card_free(dreamcastcard->card);
+free_card:
kfree(dreamcastcard);
return err;
}
--
2.54.0