From 176cf2e12a289f9f94666e188c79fa6cc1ff249b Mon Sep 17 00:00:00 2001 From: Roman Smirnov Date: Tue, 2 Jul 2024 11:49:07 +0300 Subject: [PATCH] shared/vcp: add NULL checks to foreach_vocs_service() 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 --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); -- 2.47.3