Skip to content

Commit

Permalink
ifmedia: Reset ifm_media and ifm_cur in ifmedia_removeall()
Browse files Browse the repository at this point in the history
This function may be called by NIC drivers on non-detach path, so
we need to make sure everything of ifmedia are in sane state.
  • Loading branch information
Sepherosa Ziehau committed Nov 25, 2015
1 parent 21ba42d commit 1e19ab2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sys/net/if_media.c
Expand Up @@ -91,11 +91,12 @@ ifmedia_removeall(struct ifmedia *ifm)
{
struct ifmedia_entry *entry;

for (entry = LIST_FIRST(&ifm->ifm_list); entry;
entry = LIST_FIRST(&ifm->ifm_list)) {
while ((entry = LIST_FIRST(&ifm->ifm_list)) != NULL) {
LIST_REMOVE(entry, ifm_list);
kfree(entry, M_IFADDR);
}
ifm->ifm_cur = NULL;
ifm->ifm_media = IFM_NONE;
}

/*
Expand Down

0 comments on commit 1e19ab2

Please sign in to comment.