mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: 6fire: Use common error handling code in usb6fire_control_init()
@ 2026-06-10 17:02 Markus Elfring
  2026-06-10 17:48 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-10 17:02 UTC (permalink / raw)
  To: linux-sound, Cássio Gabriel, Jaroslav Kysela, Kees Cook,
	Takashi Iwai
  Cc: LKML, kernel-janitors

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: 6fire: Use common error handling code in usb6fire_control_init()
  2026-06-10 17:02 [PATCH] ALSA: 6fire: Use common error handling code in usb6fire_control_init() Markus Elfring
@ 2026-06-10 17:48 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-06-10 17:48 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-sound, Cássio Gabriel, Jaroslav Kysela, Kees Cook,
	Takashi Iwai, LKML, kernel-janitors

On Wed, 10 Jun 2026 19:02:39 +0200,
Markus Elfring wrote:
> 
> 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>

Applied to for-next branch now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-10 17:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 17:02 [PATCH] ALSA: 6fire: Use common error handling code in usb6fire_control_init() Markus Elfring
2026-06-10 17:48 ` Takashi Iwai

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®