From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] gatt: Fix crash when a device is removed
Date: Tue, 19 Jan 2021 11:35:12 -0800 [thread overview]
Message-ID: <20210119193512.821918-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
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(-)
diff --git a/src/gatt-database.c b/src/gatt-database.c
index d99604826..d635c3214 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -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) {
--
2.26.2
next reply other threads:[~2021-01-19 19:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 19:35 Luiz Augusto von Dentz [this message]
2021-01-19 20:27 ` [BlueZ] gatt: Fix crash when a device is removed bluez.test.bot
2021-01-20 22:06 ` 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=20210119193512.821918-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.