linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacek Konieczny <jajcus@jajcus.net>
To: linux-bluetooth@vger.kernel.org
Cc: Jacek Konieczny <jajcus@jajcus.net>
Subject: [PATCH BlueZ 1/1] Free ALSA seq resources in midi_device_remove()
Date: Mon,  1 Nov 2021 14:49:18 +0100	[thread overview]
Message-ID: <20211101134918.69565-2-jajcus@jajcus.net> (raw)
In-Reply-To: <20211101134918.69565-1-jajcus@jajcus.net>

Sometimes, on connection error, this gets called and frees the device
when midi_disconnect() was not called which would leave ALSA sequencer
objects leaking.
---
 profiles/midi/midi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/profiles/midi/midi.c b/profiles/midi/midi.c
index 737d1b5f6..f644d47e9 100644
--- a/profiles/midi/midi.c
+++ b/profiles/midi/midi.c
@@ -255,6 +255,16 @@ 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);
+		midi->seq_handle = NULL;
+	}
+
 	btd_device_unref(midi->dev);
 	g_free(midi);
 }
-- 
2.25.1


  reply	other threads:[~2021-11-01 13:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 13:49 [PATCH BlueZ 0/1] Free ALSA seq resources in midi_device_remove() Jacek Konieczny
2021-11-01 13:49 ` Jacek Konieczny [this message]
2021-11-01 14:35   ` bluez.test.bot
2021-11-04  0:39     ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211101134918.69565-2-jajcus@jajcus.net \
    --to=jajcus@jajcus.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).