diff mbox series

[BlueZ,v1] shared/vcp: add NULL checks to foreach_vocs_service()

Message ID 20240702084907.26066-1-r.smirnov@omp.ru
State Superseded
Headers show
Series [BlueZ,v1] shared/vcp: add NULL checks to foreach_vocs_service() | expand

Commit Message

Roman Smirnov July 2, 2024, 8:49 a.m. UTC
Make foreach_vocs_service() safe for passing NULL pointers.

Found with the SVACE static analysis tool.
---
 src/shared/vcp.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/vcp.c b/src/shared/vcp.c
index b7e17e448..06264a241 100644
--- a/src/shared/vcp.c
+++ b/src/shared/vcp.c
@@ -2701,6 +2701,9 @@  static void foreach_vocs_service(struct gatt_db_attribute *attr,
 	struct bt_vcp *vcp = user_data;
 	struct bt_vocs *vocs = vcp_get_vocs(vcp);
 
+	if (!vocs || !attr)
+		return;
+
 	vocs->service = attr;
 
 	gatt_db_service_set_claimed(attr, true);