Skip to content

Commit 31d8988

Browse files
Moral-Haopavmick
authored andcommitted
Apply patch #10358: preserve dhcp memory type flag
1 parent f877b45 commit 31d8988

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/core/ipv4/dhcp.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,6 @@ dhcp_set_struct(struct netif *netif, struct dhcp *dhcp)
773773
* @ingroup dhcp4
774774
* Removes a struct dhcp from a netif.
775775
*
776-
* ATTENTION: Only use this when not using dhcp_set_struct() to allocate the
777-
* struct dhcp since the memory is passed back to the heap.
778-
*
779776
* @param netif the netif from which to remove the struct dhcp
780777
*/
781778
void dhcp_cleanup(struct netif *netif)
@@ -811,6 +808,7 @@ dhcp_start(struct netif *netif)
811808
{
812809
struct dhcp *dhcp;
813810
err_t result;
811+
u8_t saved_flags;
814812

815813
LWIP_ASSERT_CORE_LOCKED();
816814
LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;);
@@ -846,9 +844,10 @@ dhcp_start(struct netif *netif)
846844
/* dhcp is cleared below, no need to reset flag*/
847845
}
848846

849-
/* clear data structure */
847+
/* clear data structure but preserve DHCP_FLAG_EXTERNAL_MEM for dhcp_cleanup() */
848+
saved_flags = dhcp->flags;
850849
memset(dhcp, 0, sizeof(struct dhcp));
851-
/* dhcp_set_state(&dhcp, DHCP_STATE_OFF); */
850+
dhcp->flags = saved_flags & DHCP_FLAG_EXTERNAL_MEM;
852851

853852

854853
#if LWIP_DHCP_DOES_ACD_CHECK

0 commit comments

Comments
 (0)