Skip to contentSkip to conversation

mesh: Fix segmentation fault when removing a node

PATCH In review Inga Stotland 2 participants 2 messages Jul 4, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
mesh/node.c +5 -1
index ad94d885c..8e9da8988 100644
@@ -260,12 +260,16 @@ static void free_node_resources(void *data)
 	/* Unregister io callbacks */
 	if (node->net)
 		mesh_net_detach(node->net);
+
 	mesh_net_free(node->net);
+	node->net = NULL;
 
 	l_queue_destroy(node->elements, element_free);
-	l_free(node->comp);
+	node->elements = NULL;
 
 	free_node_dbus_resources(node);
+
+	l_free(node->comp);
 	l_free(node);
 }
 
Signature · 1 line
2.21.0
#1 lore raw

Applied with agreed upon minor adjustments, which have been build and run tested.

Quoted 29 lines · Inga Stotland

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
mesh/node.c +5 -1
index ad94d885c..8e9da8988 100644
@@ -260,12 +260,16 @@ static void free_node_resources(void *data)
 	/* Unregister io callbacks */
 	if (node->net)
 		mesh_net_detach(node->net);
+
 	mesh_net_free(node->net);
+	node->net = NULL;
 
 	l_queue_destroy(node->elements, element_free);
-	l_free(node->comp);
+	node->elements = NULL;
 
 	free_node_dbus_resources(node);
+
+	l_free(node->comp);
 	l_free(node);
 }