Skip to content

Commit 0ed25a7

Browse files
author
Arto Kinnunen
authored
Fix errors found from coverity scan (#2386)
Fix errors found by coverity -CID: 652656, 652657, 670381, 670382: Dereference null return -CID: 652655 Improper use of negative value
1 parent 7a138f7 commit 0ed25a7

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ static if_address_entry_t *ws_bbr_slaac_generate(protocol_interface_info_entry_t
242242

243243
static void ws_bbr_slaac_remove(protocol_interface_info_entry_t *cur, uint8_t *ula_prefix)
244244
{
245-
icmpv6_slaac_prefix_update(cur, ula_prefix, 64, 0, 0);
245+
if (cur) {
246+
icmpv6_slaac_prefix_update(cur, ula_prefix, 64, 0, 0);
247+
}
248+
246249
addr_policy_table_delete_entry(ula_prefix, 64);
247250
}
248251

@@ -371,14 +374,16 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
371374
}
372375
static void ws_bbr_dhcp_server_stop(protocol_interface_info_entry_t *cur, uint8_t *global_id)
373376
{
377+
if (!cur) {
378+
return;
379+
}
374380
uint8_t temp_address[16];
375381
memcpy(temp_address, global_id, 8);
376382
memset(temp_address + 8, 0, 8);
377383
tr_debug("DHCP server deactivate %s", trace_ipv6(temp_address));
378384
DHCPv6_server_service_delete(cur->id, global_id, false);
379385
//Delete Client
380386
dhcp_client_global_address_delete(cur->id, NULL, temp_address);
381-
382387
}
383388

384389
static void ws_bbr_routing_stop(protocol_interface_info_entry_t *cur)
@@ -725,7 +730,6 @@ void ws_bbr_stop(int8_t interface_id)
725730
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
726731

727732
ws_bbr_routing_stop(cur);
728-
729733
backbone_interface_id = -1;
730734
current_instance_id++;
731735

source/6LoWPAN/ws/ws_management_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ int ws_management_node_init(
4141
protocol_interface_info_entry_t *cur;
4242

4343
cur = protocol_stack_interface_info_get_by_id(interface_id);
44+
4445
if (interface_id >= 0 && (!cur || !ws_info(cur))) {
4546
return -1;
4647
}
48+
4749
if (!network_name_ptr || !fhss_timer_ptr) {
4850
return -2;
4951
}
@@ -70,7 +72,9 @@ int ws_management_node_init(
7072
return -4;
7173
}
7274

73-
cur->ws_info->fhss_timer_ptr = fhss_timer_ptr;
75+
if (cur && ws_info(cur)) {
76+
cur->ws_info->fhss_timer_ptr = fhss_timer_ptr;
77+
}
7478

7579
return 0;
7680
}
@@ -398,7 +402,7 @@ int ws_management_channel_plan_set(
398402
protocol_interface_info_entry_t *cur;
399403

400404
cur = protocol_stack_interface_info_get_by_id(interface_id);
401-
if (interface_id >= 0 && (!cur || !ws_info(cur))) {
405+
if (!cur || !ws_info(cur)) {
402406
return -1;
403407
}
404408
cur->ws_info->hopping_schdule.channel_plan = channel_plan;

source/Security/protocols/sec_prot_keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ uint8_t sec_prot_keys_gtk_count(sec_prot_gtk_keys_t *gtks)
923923
void sec_prot_keys_ptk_installed_gtk_hash_clear_all(sec_prot_keys_t *sec_keys)
924924
{
925925
for (uint8_t index = 0; index < GTK_NUM; index++) {
926-
memset(sec_keys->ins_gtk_hash[sec_keys->gtk_set_index].hash, 0, INS_GTK_HASH_LEN);
926+
memset(sec_keys->ins_gtk_hash[index].hash, 0, INS_GTK_HASH_LEN);
927927
}
928928
sec_keys->ins_gtk_hash_set = 0;
929929
sec_keys->ins_gtk_4wh_hash_set = 0;

0 commit comments

Comments
 (0)