All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] hog: Check security level before setting
@ 2024-11-18  9:49 Jiayang Mao
  2024-11-18 11:12 ` [v1] " bluez.test.bot
  2024-11-18 15:13 ` [PATCH v1] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 6+ messages in thread
From: Jiayang Mao @ 2024-11-18  9:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: quic_chejiang

bt_gatt_client_set_security could fail if the security level is
already BT_ATT_SECURITY_MEDIUM. So, get and check the security
level before setting it.

Signed-off-by: Jiayang Mao <quic_jiaymao@quicinc.com>
---
 profiles/input/hog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 017e320f0..011cc0a88 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -191,8 +191,10 @@ static int hog_accept(struct btd_service *service)
 			return -ECONNREFUSED;
 
 		client = btd_device_get_gatt_client(device);
-		if (!bt_gatt_client_set_security(client,
-						BT_ATT_SECURITY_MEDIUM))
+		if (BT_ATT_SECURITY_MEDIUM !=
+			bt_gatt_client_get_security(client) &&
+		    !bt_gatt_client_set_security(client,
+						 BT_ATT_SECURITY_MEDIUM))
 			return -ECONNREFUSED;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-20  8:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18  9:49 [PATCH v1] hog: Check security level before setting Jiayang Mao
2024-11-18 11:12 ` [v1] " bluez.test.bot
2024-11-18 15:13 ` [PATCH v1] " Luiz Augusto von Dentz
2024-11-19  3:22   ` Jiayang Mao
2024-11-19 16:23     ` Luiz Augusto von Dentz
2024-11-20  8:12       ` Jiayang Mao

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.