Index: head/sys/dev/iwm/if_iwm.c =================================================================== --- head/sys/dev/iwm/if_iwm.c +++ head/sys/dev/iwm/if_iwm.c @@ -5014,6 +5014,8 @@ if (do_net80211) ieee80211_ifdetach(&sc->sc_ic); + iwm_phy_db_free(sc); + /* Free descriptor rings */ iwm_free_rx_ring(sc, &sc->rxq); for (i = 0; i < nitems(sc->txq); i++) Index: head/sys/dev/iwm/if_iwm_phy_db.h =================================================================== --- head/sys/dev/iwm/if_iwm_phy_db.h +++ head/sys/dev/iwm/if_iwm_phy_db.h @@ -109,4 +109,5 @@ extern int iwm_phy_db_set_section(struct iwm_softc *sc, struct iwm_calib_res_notif_phy_db *phy_db_notif); extern int iwm_send_phy_db_data(struct iwm_softc *sc); +extern void iwm_phy_db_free(struct iwm_softc *sc); #endif /* __IF_IWM_PHY_DB_H__ */ Index: head/sys/dev/iwm/if_iwm_phy_db.c =================================================================== --- head/sys/dev/iwm/if_iwm_phy_db.c +++ head/sys/dev/iwm/if_iwm_phy_db.c @@ -451,3 +451,33 @@ __func__); return 0; } + +static void +iwm_phy_db_free_section(struct iwm_softc *sc, + enum iwm_phy_db_section_type type, uint16_t chg_id) +{ + struct iwm_phy_db_entry *entry = + iwm_phy_db_get_section(sc, type, chg_id); + if (!entry) + return; + + if (entry->data != NULL) + free(entry->data, M_DEVBUF); + entry->data = NULL; + entry->size = 0; +} + +void +iwm_phy_db_free(struct iwm_softc *sc) +{ + int i; + + iwm_phy_db_free_section(sc, IWM_PHY_DB_CFG, 0); + iwm_phy_db_free_section(sc, IWM_PHY_DB_CALIB_NCH, 0); + + for (i = 0; i < IWM_NUM_PAPD_CH_GROUPS; i++) + iwm_phy_db_free_section(sc, IWM_PHY_DB_CALIB_CHG_PAPD, i); + + for (i = 0; i < IWM_NUM_TXP_CH_GROUPS; i++) + iwm_phy_db_free_section(sc, IWM_PHY_DB_CALIB_CHG_TXP, i); +}