summaryrefslogtreecommitdiff
path: root/sound/usb
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-08-23 12:20:07 +0200
committerTakashi Iwai <tiwai@suse.de>2017-08-23 12:53:57 +0200
commit731209cc041779faac963578d901cb1caacbd738 (patch)
treecadd838d5f47a871828c7ad881ee1fad45af6a91 /sound/usb
parent1ae0e4ce554fb57dc4d5e1eb8e6d302e3f18b0b4 (diff)
downloadlinux-exynos-731209cc041779faac963578d901cb1caacbd738.tar.gz
linux-exynos-731209cc041779faac963578d901cb1caacbd738.tar.bz2
linux-exynos-731209cc041779faac963578d901cb1caacbd738.zip
ALSA: usb-midi: Use common error handling code in __snd_usbmidi_create()
Add jump targets 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. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/midi.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index a35f41467237..bd9d02268724 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -2435,10 +2435,8 @@ int __snd_usbmidi_create(struct snd_card *card,
err = -ENXIO;
break;
}
- if (err < 0) {
- kfree(umidi);
- return err;
- }
+ if (err < 0)
+ goto free_midi;
/* create rawmidi device */
out_ports = 0;
@@ -2448,23 +2446,25 @@ int __snd_usbmidi_create(struct snd_card *card,
in_ports += hweight16(endpoints[i].in_cables);
}
err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports);
- if (err < 0) {
- kfree(umidi);
- return err;
- }
+ if (err < 0)
+ goto free_midi;
/* create endpoint/port structures */
if (quirk && quirk->type == QUIRK_MIDI_MIDIMAN)
err = snd_usbmidi_create_endpoints_midiman(umidi, &endpoints[0]);
else
err = snd_usbmidi_create_endpoints(umidi, endpoints);
- if (err < 0) {
- return err;
- }
+ if (err < 0)
+ goto exit;
usb_autopm_get_interface_no_resume(umidi->iface);
list_add_tail(&umidi->list, midi_list);
return 0;
+
+free_midi:
+ kfree(umidi);
+exit:
+ return err;
}
EXPORT_SYMBOL(__snd_usbmidi_create);