Skip to content

Commit ac7c90a

Browse files
author
Arto Kinnunen
authored
Fix Thread resolution client initialisation (ARMmbed#1915)
Check coap-service ID during initialisation to avoid badly initialised object.
1 parent b744186 commit ac7c90a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

source/6LoWPAN/Thread/thread_resolution_client.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,14 @@ void thread_resolution_client_init(int8_t interface_id)
293293
this->interface_id = interface_id;
294294
this->notification_cb_ptr = NULL;
295295
this->error_cb_ptr = NULL;
296-
ns_list_init(&this->queries);
297296
//TODO: Check if to use ephemeral port here
298297
this->coap_service_id = thread_management_server_service_id_get(interface_id);
298+
if (this->coap_service_id < 0) {
299+
tr_err("Thread resolution client init failed");
300+
ns_dyn_mem_free(this);
301+
return;
302+
}
303+
ns_list_init(&this->queries);
299304
ns_list_add_to_start(&instance_list, this);
300305

301306
coap_service_register_uri(this->coap_service_id, THREAD_URI_ADDRESS_NOTIFICATION, COAP_SERVICE_ACCESS_POST_ALLOWED, thread_resolution_client_notification_post_cb);

source/6LoWPAN/Thread/thread_resolution_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int thread_resolution_server_init(int8_t interface_id, thread_resolution_server_
173173
this->interface_id = interface_id;
174174
this->coap_service_id = thread_management_server_service_id_get(interface_id);
175175
if (this->coap_service_id < 0) {
176-
tr_warn("Thread resolution srv init failed");
176+
tr_err("Thread resolution srv init failed");
177177
ns_dyn_mem_free(this);
178178
return -3;
179179
}

0 commit comments

Comments
 (0)