tools/mesh-cfgclient: Fix segfault on remote node reset
authorInga Stotland <inga.stotland@intel.com>
Mon, 20 Jul 2020 20:42:06 +0000 (13:42 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
This fixes a segfault that is caused by freeeing non-allocated memory.
Happens upon the removal of a remote node when remote's net key and/or
app key queues are destroyed.

__GI___libc_free (mem=0x1) at malloc.c:3102
    destroy=destroy@entry=0x55761f63a3b0 <l_free>) at ell/queue.c:107
    destroy=destroy@entry=0x55761f63a3b0 <l_free>) at ell/queue.c:82
    at tools/mesh/remote.c:140
    at tools/mesh/cfgcli.c:764
    at tools/mesh/cfgcli.c:764
    msg=0x5576213aa6f0, user_data=<optimized out>)
    at tools/mesh-cfgclient.c:1522
    dbus=dbus@entry=0x55762132f860, message=message@entry=0x5576213aa6f0)
    at ell/dbus-service.c:1793
    user_data=0x55762132f860) at ell/dbus.c:285
    user_data=0x55762132f940) at ell/io.c:126

Change-Id: Ieaddbc0863f83780f3f3166e1665c553c8ae9b0f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
tools/mesh/remote.c

index 2a8f747..c74f0be 100644 (file)
@@ -134,10 +134,11 @@ uint8_t remote_del_node(uint16_t unicast)
                l_queue_destroy(rmt->els[i], NULL);
                remote_add_blacklisted_address(unicast + i, iv_index, true);
        }
+
        l_free(rmt->els);
 
-       l_queue_destroy(rmt->net_keys, l_free);
-       l_queue_destroy(rmt->app_keys, l_free);
+       l_queue_destroy(rmt->net_keys, NULL);
+       l_queue_destroy(rmt->app_keys, NULL);
        l_free(rmt);
 
        mesh_db_del_node(unicast);