Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1718222 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-08-23 12:30 +0200 |
| Last post | 2017-08-23 13:00 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_create() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-23 12:30 +0200
Re: [alsa-devel] [PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_create() Clemens Ladisch <clemens@ladisch.de> - 2017-08-23 13:00 +0200
Re: [PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_create() Takashi Iwai <tiwai@suse.de> - 2017-08-23 13:00 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-08-23 12:30 +0200 |
| Subject | [PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_create() |
| Message-ID | <uhB58-7JE-5@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 23 Aug 2017 12:20:07 +0200
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>
---
sound/usb/midi.c | 22 +++++++++++-----------
1 file 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);
--
2.14.0
[toc] | [next] | [standalone]
| From | Clemens Ladisch <clemens@ladisch.de> |
|---|---|
| Date | 2017-08-23 13:00 +0200 |
| Subject | Re: [alsa-devel] [PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_create() |
| Message-ID | <uhBy9-7Te-1@gated-at.bofh.it> |
| In reply to | #1718222 |
SF Markus Elfring wrote:
> 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>
> ---
> sound/usb/midi.c | 22 +++++++++++-----------
> 1 file 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);
>
[toc] | [prev] | [next] | [standalone]
| From | Takashi Iwai <tiwai@suse.de> |
|---|---|
| Date | 2017-08-23 13:00 +0200 |
| Subject | Re: [PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_create() |
| Message-ID | <uhBy9-7Te-5@gated-at.bofh.it> |
| In reply to | #1718222 |
On Wed, 23 Aug 2017 12:25:50 +0200, SF Markus Elfring wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Wed, 23 Aug 2017 12:20:07 +0200 > > 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> Applied, thanks. Takashi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web