2019-07-04 18:16:26

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ v2] 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(-)

diff --git a/mesh/node.c b/mesh/node.c
index ad94d885c..8e9da8988 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -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);
}

--
2.21.0


2019-07-04 18:16:51

by Gix, Brian

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


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

On Thu, 2019-07-04 at 10:36 -0700, Inga Stotland wrote:
> 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(-)
>
> diff --git a/mesh/node.c b/mesh/node.c
> index ad94d885c..8e9da8988 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -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);
> }
>