Skip to contentSkip to conversation

gatt: Fix crash when a device is removed

PATCH In review Luiz Augusto von Dentz 2 participants 3 messages Jan 19, 2021 – Jan 20, 2021 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 gatt: Fix crash when a device is removed

From: Luiz Augusto von Dentz <[email protected]>

If a device is removed with notifications enabled that would lead to device_state being freed while att_disconnected has not been called yet.

gh-issue: https://github.com/bluez/bluez/issues/82

---
 src/gatt-database.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
src/gatt-database.c +8 -2
index d99604826..d635c3214 100644
@@ -1350,11 +1350,17 @@ static void send_notification_to_device(void *data, void *user_data)
 	if (!ccc->value || (notify->conf && !(ccc->value & 0x0002)))
 		return;
 
-	device = btd_adapter_get_device(notify->database->adapter,
+	device = btd_adapter_find_device(notify->database->adapter,
 						&device_state->bdaddr,
 						device_state->bdaddr_type);
-	if (!device)
+	if (!device) {
+		/* If ATT has not disconnect yet don't remove the state as it
+		 * will eventually be removed when att_disconnected is called.
+		 */
+		if (device_state->disc_id)
+			return;
 		goto remove;
+	}
 
 	server = btd_device_get_gatt_server(device);
 	if (!server) {
Signature · 1 line
2.26.2
#1 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=417643

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

author maintainer
#2 lore raw

Hi,

Quoted 20 lines · On Tue, Jan 19, 2021 at 12:27 PM <[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=417643

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

Quoted 8 lines

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

Pushed.

Signature · 1 line
Luiz Augusto von Dentz