From 18d4dc1f8bd7957e7dc2bd4f8afd453eb66f41af Mon Sep 17 00:00:00 2001 From: pretoriano80 Date: Fri, 1 Apr 2022 17:00:23 +0300 Subject: [PATCH] bluez: upstream patch to fix gatt database issue This patch addresses a regression intoduced by https://github.com/bluez/bluez/commit/411d63e which caused certain bluethooth remotes to stop working correctly as reported here: https://github.com/bluez/bluez/issues/326 Original upstream patch: https://github.com/bluez/bluez/commit/234d60423c3b8186a27b31028d4c0acb847eedb1.patch The patch will close this LibreELEC issue : https://github.com/bluez/bluez/commit/234d60423c3b8186a27b31028d4c0acb847eedb1.patch --- ...z-22-Fix-gatt-db-attribute-get-index.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 packages/network/bluez/patches/bluez-22-Fix-gatt-db-attribute-get-index.patch diff --git a/packages/network/bluez/patches/bluez-22-Fix-gatt-db-attribute-get-index.patch b/packages/network/bluez/patches/bluez-22-Fix-gatt-db-attribute-get-index.patch new file mode 100644 index 0000000000..d879b5c15a --- /dev/null +++ b/packages/network/bluez/patches/bluez-22-Fix-gatt-db-attribute-get-index.patch @@ -0,0 +1,36 @@ +From 403cfc553e65318c547840516007f4cd4e872aa7 Mon Sep 17 00:00:00 2001 +From: Luiz Augusto von Dentz +Date: Fri, 1 Apr 2022 14:38:57 -0700 +Subject: [PATCH] shared/gatt-db: Fix gatt_db_attribute_get_index + +gatt_db_attribute_get_index was calculating the index based on +attrib->handle - service->attributes[0]->handle which doesn't work when +there are gaps in between handles. + +Fixes: https://github.com/bluez/bluez/issues/326 +--- + src/shared/gatt-db.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c +index be07cdbe4..4f5d10b57 100644 +--- a/src/shared/gatt-db.c ++++ b/src/shared/gatt-db.c +@@ -1537,12 +1537,12 @@ static int gatt_db_attribute_get_index(struct gatt_db_attribute *attrib) + return -1; + + service = attrib->service; +- index = attrib->handle - service->attributes[0]->handle; +- +- if (index > (service->num_handles - 1)) +- return -1; ++ for (index = 0; index < service->num_handles; index++) { ++ if (service->attributes[index] == attrib) ++ return index; ++ } + +- return index; ++ return -1; + } + + static struct gatt_db_attribute * \ No newline at end of file