Skip to contentSkip to conversation

ALSA: 6Fire: Use common error handling code in usb6fire_chip_probe()

PATCH Applied SF Markus Elfring 2 participants 2 messages Sep 6, 2017 – Sep 7, 2017

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

PATCH 1/1 ALSA: 6Fire: Use common error handling code in usb6fire_chip_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 6 Sep 2017 16:26:29 +0200

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

This issue was detected by using the Coccinelle software.

---
 sound/usb/6fire/chip.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)
sound/usb/6fire/chip.c +13 -18
index bc2a24f7a791..c7641cb50616 100644
@@ -143,37 +143,32 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
 	chip->card = card;
 
 	ret = usb6fire_comm_init(chip);
-	if (ret < 0) {
-		usb6fire_chip_destroy(chip);
-		return ret;
-	}
+	if (ret < 0)
+		goto destroy_chip;
 
 	ret = usb6fire_midi_init(chip);
-	if (ret < 0) {
-		usb6fire_chip_destroy(chip);
-		return ret;
-	}
+	if (ret < 0)
+		goto destroy_chip;
 
 	ret = usb6fire_pcm_init(chip);
-	if (ret < 0) {
-		usb6fire_chip_destroy(chip);
-		return ret;
-	}
+	if (ret < 0)
+		goto destroy_chip;
 
 	ret = usb6fire_control_init(chip);
-	if (ret < 0) {
-		usb6fire_chip_destroy(chip);
-		return ret;
-	}
+	if (ret < 0)
+		goto destroy_chip;
 
 	ret = snd_card_register(card);
 	if (ret < 0) {
 		dev_err(&intf->dev, "cannot register card.");
-		usb6fire_chip_destroy(chip);
-		return ret;
+		goto destroy_chip;
 	}
 	usb_set_intfdata(intf, chip);
 	return 0;
+
+destroy_chip:
+	usb6fire_chip_destroy(chip);
+	return ret;
 }
 
 static void usb6fire_chip_disconnect(struct usb_interface *intf)
Signature · 1 line
2.14.1
Applied
#1 lore raw
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Sep 2017 16:26:29 +0200

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi