mesh: Fix segmentation fault when removing a node
authorInga Stotland <inga.stotland@intel.com>
Thu, 4 Jul 2019 17:36:06 +0000 (10:36 -0700)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 17 Dec 2019 15:21:21 +0000 (20:51 +0530)
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.

Change-Id: I97d395e354ed8b21b9ec55d2eea924d7b1db9175
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
mesh/node.c

index b21881a..2a46e4f 100644 (file)
@@ -262,12 +262,14 @@ 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);
-       l_free(node->comp);
+       node->elements = NULL;
 
        free_node_dbus_resources(node);
+
+       mesh_net_free(node->net);
+       l_free(node->comp);
        l_free(node);
 }