Fix the svace issue (DEREF_OF_NULL)
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-mesh-dbus-handler.c
index e1d12b0..0b9f872 100644 (file)
@@ -1419,6 +1419,10 @@ static struct l_dbus_message *__mesh_agent_prompt_numeric_request(
 
        l = g_slist_find_custom(mesh_apps, net_uuid,
                        __mesh_compare_network_uuid);
+       if (!l) {
+               g_free(net_uuid);
+               return NULL;
+       }
        app = l->data;
 
        memset(&ev, 0, sizeof(ev));
@@ -1464,7 +1468,7 @@ static struct l_dbus_message *__mesh_agent_prompt_static_request(
        uint8_t *net_uuid;
        const char *dbus_path;
        GSList *l;
-       meshcfg_app *app;
+       meshcfg_app *app = NULL;
 
        dbus_path =  l_dbus_message_get_path(msg);
        net_uuid = __mesh_get_net_uuid_from_path(dbus_path, true,
@@ -1474,7 +1478,13 @@ static struct l_dbus_message *__mesh_agent_prompt_static_request(
 
        l = g_slist_find_custom(mesh_apps, net_uuid,
                        __mesh_compare_network_uuid);
-       app = l->data;
+
+       if (l) {
+               app = l->data;
+       } else {
+               ERR("Mesh: app not found");
+       }
+
 
        memset(&ev, 0, sizeof(ev));
        memcpy(ev.net_uuid, net_uuid, 16);
@@ -1485,7 +1495,10 @@ static struct l_dbus_message *__mesh_agent_prompt_static_request(
 
                struct hal_ev_mesh_provision_finished ev;
                memset(&ev, 0, sizeof(ev));
-               memcpy(ev.net_uuid, app->uuid, 16);
+
+               if (app)
+                       memcpy(ev.net_uuid, app->uuid, 16);
+
                ev.status = BT_STATUS_FAIL;
                ev.reason = BT_HAL_MESH_PROV_ERR_INTERNAL;
                if (mesh_event_cb)
@@ -1782,6 +1795,8 @@ void __bt_mesh_enable_scanning_timer(uint8_t *net_uuid, uint16_t secs)
        meshcfg_app *app;
        l = g_slist_find_custom(mesh_apps, net_uuid,
                        __mesh_compare_network_uuid);
+       if (!l)
+               return;
        app = l->data;
 
        if (app->scan_timer_id > 0) {
@@ -2309,7 +2324,6 @@ static void __bt_hal_mesh_delete_node_setup(struct l_dbus_message *msg,
        l_dbus_message_set_arguments(msg, "qy",
                node_info->unicast, node_info->num_elements);
        INFO("Mesh: Delete Remote Node Setup params passed");
-       g_free(node_info);
 }
 
 static void __bt_hal_mesh_delete_node_reply(