]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: 6fire: Use common error handling code in usb6fire_control_init()
authorMarkus Elfring <elfring@users.sourceforge.net>
Wed, 10 Jun 2026 16:57:17 +0000 (18:57 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 10 Jun 2026 17:47:49 +0000 (19:47 +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>
Link: https://patch.msgid.link/a24a6bd9-a8e1-423c-9eae-b9ab08a8de81@web.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/6fire/control.c

index c77a21a9acd796d09bafbb22e16f013da54178d2..10104cb421659ceadec8e9e3ffb12ec9517fcb8e 100644 (file)
@@ -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)