diff mbox series

[BlueZ,v2] shared/csip: add NULL checks to foreach_csis_service()

Message ID 20240702090120.33631-1-r.smirnov@omp.ru
State Superseded
Headers show
Series [BlueZ,v2] shared/csip: add NULL checks to foreach_csis_service() | expand

Commit Message

Roman Smirnov July 2, 2024, 9:01 a.m. UTC
Make foreach_csis_service() safe for passing NULL pointers.

Found with the SVACE static analysis tool.
---
 V1 -> V2: added check for attr

 src/shared/csip.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/csip.c b/src/shared/csip.c
index 87b4590d9..9a734e7d6 100644
--- a/src/shared/csip.c
+++ b/src/shared/csip.c
@@ -611,6 +611,9 @@  static void foreach_csis_service(struct gatt_db_attribute *attr,
 	struct bt_csip *csip = user_data;
 	struct bt_csis *csis = csip_get_csis(csip);
 
+	if (!csis || !attr)
+		return;
+
 	csis->service = attr;
 
 	gatt_db_service_set_claimed(attr, true);