Skip to content

dhcpv4: fix segfault when disabling interface#381

Open
mmmspatz wants to merge 1 commit intoopenwrt:masterfrom
mmmspatz:mspatz/fix_avl_page_fault
Open

dhcpv4: fix segfault when disabling interface#381
mmmspatz wants to merge 1 commit intoopenwrt:masterfrom
mmmspatz:mspatz/fix_avl_page_fault

Conversation

@mmmspatz
Copy link

dhcpv4_free_lease already calls avl_delete() on the node it's freeing, and thus shouldn't be called inside an avl_remove_all_elements() loop.

Use avl_for_each_element_safe() instead. Its documentation says: "This loop can be used if the current element might be removed from the tree during the loop."

Fixes: #371

@mmmspatz
Copy link
Author

Supersedes #376

dhcpv4_free_lease already calls avl_delete() on the node it's freeing,
and thus shouldn't be called inside an avl_remove_all_elements() loop.

Use avl_for_each_element_safe() instead. Its documentation says:
"This loop can be used if the current element might be removed from the
tree during the loop."

Fixes: openwrt#371
Signed-off-by: Mark H. Spatz <mark.h.spatz@gmail.com>
@mmmspatz mmmspatz force-pushed the mspatz/fix_avl_page_fault branch from 4bddf1a to f641760 Compare February 18, 2026 17:01
@mmmspatz mmmspatz changed the title dhcpv4: fix segfault when tearing down interface with active leases dhcpv4: fix segfault when disabling interface Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

odhcpd do_page_fault()

1 participant

Comments