Skip to contentSkip to conversation

Free ALSA seq resources in midi_device_remove()

PATCH Applied Jacek Konieczny 3 participants 4 messages Nov 1, 2021 – Nov 4, 2021 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

cover Free ALSA seq resources in midi_device_remove()

I am having problem connecting via Bluetooth LE MID to my VOX Adio Air GT guitar amplifier. I was not able to debug the connection problem yet, but there was a bigger problem on hand: due to constant connecting/disconnecting ALSA seq resources were leaking until bluetoothd hung and ALSA backend crashed.

I have described a bit more in the github issue: https://github.com/bluez/bluez/issues/225

I was able to fix the leak with the following patch. I am not sure if that is the right way to do this, though. As the relation between midi_disconnect() and midi_device_remove() functions is not clear to me, I have just copied some of the cleanup code from one to the other.

Jacek Konieczny (1):
Free ALSA seq resources in midi_device_remove()

 profiles/midi/midi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 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.

---
 profiles/midi/midi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
profiles/midi/midi.c +10 -0
index 737d1b5f6..f644d47e9 100644
@@ -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);
 }
Signature · 1 line
2.25.1
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=573565

---Test result---

Test Summary:

CheckPatch                    PASS      1.43 seconds
GitLint                       PASS      0.89 seconds
Prep - Setup ELL              PASS      46.37 seconds
Build - Prep                  PASS      0.50 seconds
Build - Configure             PASS      8.57 seconds
Build - Make                  PASS      202.34 seconds
Make Check                    PASS      9.49 seconds
Make Distcheck                PASS      242.98 seconds
Build w/ext ELL - Configure   PASS      8.72 seconds
Build w/ext ELL - Make        PASS      191.05 seconds

---
Regards,
Linux Bluetooth

maintainer Applied
#3 lore raw

Hi Jacek,

Quoted 25 lines · On Mon, Nov 1, 2021 at 7:36 AM <[email protected]> wrote:

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=573565

---Test result---

Test Summary:

CheckPatch                    PASS      1.43 seconds
GitLint                       PASS      0.89 seconds
Prep - Setup ELL              PASS      46.37 seconds
Build - Prep                  PASS      0.50 seconds
Build - Configure             PASS      8.57 seconds
Build - Make                  PASS      202.34 seconds
Make Check                    PASS      9.49 seconds
Make Distcheck                PASS      242.98 seconds
Build w/ext ELL - Configure   PASS      8.72 seconds
Build w/ext ELL - Make        PASS      191.05 seconds
Quoted 3 lines

---
Regards,
Linux Bluetooth

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz