From: Markus Elfring <Markus.Elfring@web.de>
To: linux-sound@vger.kernel.org,
"Cássio Gabriel" <cassiogabrielcontato@gmail.com>,
"Jaroslav Kysela" <perex@perex.cz>, "Kees Cook" <kees@kernel.org>,
"Takashi Iwai" <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] ALSA: 6fire: Use common error handling code in usb6fire_control_init()
Date: Wed, 10 Jun 2026 19:02:39 +0200 [thread overview]
Message-ID: <a24a6bd9-a8e1-423c-9eae-b9ab08a8de81@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jun 2026 18:57:17 +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@users.sourceforge.net>
---
sound/usb/6fire/control.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/sound/usb/6fire/control.c b/sound/usb/6fire/control.c
index c77a21a9acd7..10104cb42165 100644
--- a/sound/usb/6fire/control.c
+++ b/sound/usb/6fire/control.c
@@ -582,30 +582,31 @@ int usb6fire_control_init(struct sfire_chip *chip)
"Master Playback Volume", vol_elements);
if (ret) {
dev_err(&chip->dev->dev, "cannot add control.\n");
- kfree(rt);
- return ret;
+ goto free_rt;
}
ret = usb6fire_control_add_virtual(rt, chip->card,
"Master Playback Switch", mute_elements);
if (ret) {
dev_err(&chip->dev->dev, "cannot add control.\n");
- kfree(rt);
- return ret;
+ goto free_rt;
}
i = 0;
while (elements[i].name) {
ret = snd_ctl_add(chip->card, snd_ctl_new1(&elements[i], rt));
if (ret < 0) {
- kfree(rt);
dev_err(&chip->dev->dev, "cannot add control.\n");
- return ret;
+ goto free_rt;
}
i++;
}
chip->control = rt;
return 0;
+
+free_rt:
+ kfree(rt);
+ return ret;
}
void usb6fire_control_abort(struct sfire_chip *chip)
--
2.54.0
next reply other threads:[~2026-06-10 17:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 17:02 Markus Elfring [this message]
2026-06-10 17:48 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a24a6bd9-a8e1-423c-9eae-b9ab08a8de81@web.de \
--to=markus.elfring@web.de \
--cc=cassiogabrielcontato@gmail.com \
--cc=kees@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®