Skip to content

Conversation

@LuskeyNoah
Copy link
Contributor

The net_mgmt APIs net_mgmt_event_wait_... add a stack-allocated callback to the list of callbacks, but don't delete it once before the function returns. This results in a memory access error if that net_mgmt event later occurs.

This change always removes the net_mgmt callback after the wait is complete.

The net_mgmt APIs `net_mgmt_event_wait_...` add a stack-allocated
callback to the list of callbacks, but don't delete it once before
the function returns. This results in a memory access error if
that net_mgmt event later occurs.

This change *always* removes the net_mgmt callback after the wait
is complete.

ret = k_sem_take(sync.sync_call, timeout);

net_mgmt_del_event_callback(&sync);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the thing is, the mgmt thread removes this event callback before feeding the semaphore (https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/net/ip/net_mgmt.c#L175). So in case k_sem_take() reports no error, the callback shouldn't even be present on the list anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're absolutely right - internally I was using an older release that was missing #62302. Incorporating that and will close this PR.

@LuskeyNoah LuskeyNoah closed this Nov 24, 2023
@LuskeyNoah LuskeyNoah deleted the noah/fix-net_mgmt-segfault branch November 24, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants