From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Sat, 11 Nov 2017 11:36:25 +0100 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. Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- sound/core/rawmidi.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index c17f173150e9..34686000ecce 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1560,10 +1560,8 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, ->streams[SNDRV_RAWMIDI_STREAM_INPUT], SNDRV_RAWMIDI_STREAM_INPUT, input_count); - if (err < 0) { - snd_rawmidi_free(rmidi); - return err; - } + if (err < 0) + goto free_midi; err = snd_rawmidi_alloc_substreams(rmidi, @@ -1571,19 +1569,20 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, ->streams[SNDRV_RAWMIDI_STREAM_OUTPUT], SNDRV_RAWMIDI_STREAM_OUTPUT, output_count); - if (err < 0) { - snd_rawmidi_free(rmidi); - return err; - } + if (err < 0) + goto free_midi; err = snd_device_new(card, SNDRV_DEV_RAWMIDI, rmidi, &ops); - if (err < 0) { - snd_rawmidi_free(rmidi); - return err; - } + if (err < 0) + goto free_midi; + if (rrawmidi) *rrawmidi = rmidi; return 0; + +free_midi: + snd_rawmidi_free(rmidi); + return err; } EXPORT_SYMBOL(snd_rawmidi_new); -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html