From 999bbc349cd715d8ce9ad8e61f382adda2169b47 Mon Sep 17 00:00:00 2001 From: Juha Heiskanen Date: Thu, 11 Oct 2018 12:01:12 +0300 Subject: [PATCH] Copied memory fix from PR #1858 Change-Id: I3c0a741dd57795911d74d3e9b2c6ac92a818bfe8 --- source/DHCPv6_client/dhcpv6_client_service.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/DHCPv6_client/dhcpv6_client_service.c b/source/DHCPv6_client/dhcpv6_client_service.c index 918be035752..33ad2fc23d9 100644 --- a/source/DHCPv6_client/dhcpv6_client_service.c +++ b/source/DHCPv6_client/dhcpv6_client_service.c @@ -268,7 +268,7 @@ void dhcpv6_renew(protocol_interface_info_entry_t *interface, if_address_entry_t payload_len = libdhcpv6_address_request_message_len(srv_data_ptr->clientLinkIdType, srv_data_ptr->serverLinkType, 0); payload_ptr = ns_dyn_mem_temporary_alloc(payload_len); if (payload_ptr == NULL) { - addr->state_timer = 200;//Retry after? should there be maximum 20 second retry + addr->state_timer = 200; //Retry after 20 seconds tr_error("Out of memory"); return ; } @@ -292,6 +292,11 @@ void dhcpv6_renew(protocol_interface_info_entry_t *interface, if_address_entry_t libdhcpv6_generic_nontemporal_address_message_write(payload_ptr, &packetReq, &nonTemporalAddress, &serverLink); // send solicit srv_data_ptr->transActionId = dhcp_service_send_req(dhcp_client.service_instance, 0, srv_data_ptr, srv_data_ptr->server_address, payload_ptr, payload_len, dhcp_solicit_resp_cb); + if (srv_data_ptr->transActionId == 0) { + ns_dyn_mem_free(payload_ptr); + addr->state_timer = 200; //Retry after 20 seconds + tr_error("DHCP renew send failed"); + } } void dhcpv6_client_set_address(int8_t interface_id, dhcpv6_client_server_data_t *srv_data_ptr)