From: Jacek Konieczny Date: Mon, 1 Nov 2021 13:49:18 +0000 (+0100) Subject: midi: Free ALSA seq resources in midi_device_remove() X-Git-Tag: submit/tizen/20220313.220938~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b196ca51f0ebb98e1c5a19e25622a0f42b08ca6c;p=platform%2Fupstream%2Fbluez.git midi: Free ALSA seq resources in midi_device_remove() Sometimes, on connection error, this gets called and frees the device when midi_disconnect() was not called which would leave ALSA sequencer objects leaking. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- diff --git a/profiles/midi/midi.c b/profiles/midi/midi.c index 737d1b5f..40064df3 100644 --- a/profiles/midi/midi.c +++ b/profiles/midi/midi.c @@ -255,6 +255,15 @@ static void midi_device_remove(struct btd_service *service) return; } + if (midi->seq_handle) { + midi_read_free(&midi->midi_in); + midi_write_free(&midi->midi_out); + io_destroy(midi->io); + snd_seq_delete_simple_port(midi->seq_handle, midi->seq_port_id); + midi->seq_port_id = 0; + snd_seq_close(midi->seq_handle); + } + btd_device_unref(midi->dev); g_free(midi); }