提交 731209cc 编写于 作者: M Markus Elfring 提交者: Takashi Iwai

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: NMarkus Elfring <elfring@users.sourceforge.net>
Acked-by: NClemens Ladisch <clemens@ladisch.de>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 1ae0e4ce
...@@ -2435,10 +2435,8 @@ int __snd_usbmidi_create(struct snd_card *card, ...@@ -2435,10 +2435,8 @@ int __snd_usbmidi_create(struct snd_card *card,
err = -ENXIO; err = -ENXIO;
break; break;
} }
if (err < 0) { if (err < 0)
kfree(umidi); goto free_midi;
return err;
}
/* create rawmidi device */ /* create rawmidi device */
out_ports = 0; out_ports = 0;
...@@ -2448,23 +2446,25 @@ int __snd_usbmidi_create(struct snd_card *card, ...@@ -2448,23 +2446,25 @@ int __snd_usbmidi_create(struct snd_card *card,
in_ports += hweight16(endpoints[i].in_cables); in_ports += hweight16(endpoints[i].in_cables);
} }
err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports); err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports);
if (err < 0) { if (err < 0)
kfree(umidi); goto free_midi;
return err;
}
/* create endpoint/port structures */ /* create endpoint/port structures */
if (quirk && quirk->type == QUIRK_MIDI_MIDIMAN) if (quirk && quirk->type == QUIRK_MIDI_MIDIMAN)
err = snd_usbmidi_create_endpoints_midiman(umidi, &endpoints[0]); err = snd_usbmidi_create_endpoints_midiman(umidi, &endpoints[0]);
else else
err = snd_usbmidi_create_endpoints(umidi, endpoints); err = snd_usbmidi_create_endpoints(umidi, endpoints);
if (err < 0) { if (err < 0)
return err; goto exit;
}
usb_autopm_get_interface_no_resume(umidi->iface); usb_autopm_get_interface_no_resume(umidi->iface);
list_add_tail(&umidi->list, midi_list); list_add_tail(&umidi->list, midi_list);
return 0; return 0;
free_midi:
kfree(umidi);
exit:
return err;
} }
EXPORT_SYMBOL(__snd_usbmidi_create); EXPORT_SYMBOL(__snd_usbmidi_create);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册