2019-07-04 18:15:04

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ] mesh: Fix segmentation fault when removing a node

This fixes a segmentation fault introduced by earlier changes.
Segmentation fault was used by accessing a queu that has been
destroyed, but the corresponding pointer hasn't been set to NULL.
---
mesh/node.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mesh/node.c b/mesh/node.c
index ad94d885c..40b5256ec 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -222,7 +222,9 @@ static void element_free(void *data)
struct node_element *element = data;

l_queue_destroy(element->models, mesh_model_free);
+ element->models = NULL;
l_free(element->path);
+ element->path = NULL;
l_free(element);
}

@@ -260,9 +262,12 @@ static void free_node_resources(void *data)
/* Unregister io callbacks */
if (node->net)
mesh_net_detach(node->net);
+
mesh_net_free(node->net);

l_queue_destroy(node->elements, element_free);
+ node->elements = NULL;
+
l_free(node->comp);

free_node_dbus_resources(node);
--
2.21.0