diff mbox series

[BlueZ,v2] gatt-server: fix memory leak in bt_gatt_server_send_notification()

Message ID 20240628075719.42796-1-r.smirnov@omp.ru
State New
Headers show
Series [BlueZ,v2] gatt-server: fix memory leak in bt_gatt_server_send_notification() | expand

Commit Message

Roman Smirnov June 28, 2024, 7:57 a.m. UTC
data-pdu is allocated but not released when an error occurs.

Add data-pdu release before exiting the function in case of an error.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
---
 src/shared/gatt-server.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 0e399ceb1..3a53d5dfd 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -1822,8 +1822,10 @@  bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
 	return result;
 
 error:
-	if (data)
+	if (data) {
+		free(data->pdu);
 		free(data);
+	}
 
 	return false;
 }