Skip to contentSkip to conversation

ALSA: 6fire: Use common error handling code in usb6fire_control_init()

PATCH Applied Markus Elfring 2 participants 2 messages Jun 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: 6fire: Use common error handling code in usb6fire_control_init()

From: Markus Elfring <[email protected]>
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.

---
 sound/usb/6fire/control.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sound/usb/6fire/control.c +7 -6
index c77a21a9acd7..10104cb42165 100644
@@ -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)
Signature · 1 line
2.54.0
Applied
#1 lore raw
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
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.

Applied to for-next branch now. Thanks.

Takashi