<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 1528118a8f84b4b178729c1f9fc3f6d858c04f9f Mon Sep 17 00:00:00 2001
From: Xiao Yao &lt;xiaoyao@rock-chips.com&gt;
Date: Sun, 17 Dec 2023 21:50:12 +0800
Subject: [PATCH] adapter: Fix link key address type for old kernels

Fixes: https://github.com/bluez/bluez/issues/686

Signed-off-by: Xiao Yao &lt;xiaoyao@rock-chips.com&gt;
---
 src/adapter.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/adapter.c b/src/adapter.c
index ee70b00d2..b4628a411 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4347,7 +4347,17 @@ static void load_link_keys(struct btd_adapter *adapter, GSList *keys,
 		struct link_key_info *info = l-&gt;data;
 
 		bacpy(&amp;key-&gt;addr.bdaddr, &amp;info-&gt;bdaddr);
-		key-&gt;addr.type = info-&gt;bdaddr_type;
+
+		/*
+		 * According to the Bluetooth specification, the address
+		 * type of the link key is not fixed. However, the
+		 * load_link_keys function in the old kernel code requires
+		 * that the address type must be BREDR. Since the address
+		 * type is not actually used by the link key, to maintain
+		 * compatibility with older kernel versions, the addr.type
+		 * of the link key is set to BDADDR_BREDR.
+		 */
+		key-&gt;addr.type = BDADDR_BREDR;
 		key-&gt;type = info-&gt;type;
 		memcpy(key-&gt;val, info-&gt;key, 16);
 		key-&gt;pin_len = info-&gt;pin_len;
</pre></body></html>