diff --git a/src/core/agent.c b/src/core/agent.c
index a8065b82c4cb23e0e1cda6fa78057421355a8ef9..b79638c8da76db838024f997813c15231ac1c768 100644
--- a/src/core/agent.c
+++ b/src/core/agent.c
@@ -3114,10 +3114,10 @@ void parse_scanresults(struct ubus_request *req, int type, struct blob_attr *msg
 			continue;
 		// if no neighbors, allocated
 		if (scanres_el->num_neighbors == 0) {
-			scanres_el->num_neighbors++;
-			scanres_el->nbrlist = malloc(1 * sizeof(*(scanres_el->nbrlist)));
+			scanres_el->nbrlist = calloc(1, 1 * sizeof(*(scanres_el->nbrlist)));
 			if (!scanres_el)
 				continue;
+			scanres_el->num_neighbors++;
 		}
 		// If has neighbors, allocate one addiotnal neighbor
 		else {
diff --git a/src/core/agent_map.c b/src/core/agent_map.c
index d2ec539024de7e191185f9d9801fcb470dbd5431..4f26dbfb539de406f965d4b1b84f669f070defd7 100644
--- a/src/core/agent_map.c
+++ b/src/core/agent_map.c
@@ -3019,7 +3019,9 @@ void free_scanresults_neighbors(struct wifi_radio_element *re)
 		for (k = 0; k < opclass->num_channels_scanned; k++) {
 			struct wifi_scanres_channel_element *ch_el = &opclass->channel_scanlist[k];
 
-			free(ch_el->nbrlist);
+			if (ch_el->nbrlist)
+				free(ch_el->nbrlist);
+			ch_el->nbrlist = NULL;
 			ch_el->num_neighbors = 0;
 		}
 	}
@@ -3055,8 +3057,6 @@ int handle_channel_scan_request(void *agent, struct cmdu_cstruct *cmdu)
 	char *radio_name;
 	wifi_object_t r_wobj = WIFI_OBJECT_INVALID;
 
-	free_scanresults_neighbors(radio);
-
 	for (i = 0; i < query->nbr_radios; i++) { // a->num_radios
 		radio_name = wifi_get_radio_by_mac(a, query->radio_data[i].radio_id);
 		if (!radio_name)
@@ -3067,6 +3067,7 @@ int handle_channel_scan_request(void *agent, struct cmdu_cstruct *cmdu)
 			continue;
 		ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
 		// ubus call wifi.radio.wl0 scan
+		free_scanresults_neighbors(&a->radios[ri]);
 		ubus_call_object(a, r_wobj, "scan", NULL, &a->radios[ri]);
 		trace("Scaning radio %s neighbors...\n", wifi_get_radio_by_mac(a, query->radio_data[i].radio_id));
 	}