Index: head/sys/netinet/cc/cc_chd.c =================================================================== --- head/sys/netinet/cc/cc_chd.c +++ head/sys/netinet/cc/cc_chd.c @@ -307,8 +307,7 @@ chd_cb_destroy(struct cc_var *ccv) { - if (ccv->cc_data != NULL) - free(ccv->cc_data, M_CHD); + free(ccv->cc_data, M_CHD); } static int Index: head/sys/netinet/cc/cc_cubic.c =================================================================== --- head/sys/netinet/cc/cc_cubic.c +++ head/sys/netinet/cc/cc_cubic.c @@ -213,9 +213,7 @@ static void cubic_cb_destroy(struct cc_var *ccv) { - - if (ccv->cc_data != NULL) - free(ccv->cc_data, M_CUBIC); + free(ccv->cc_data, M_CUBIC); } static int Index: head/sys/netinet/cc/cc_dctcp.c =================================================================== --- head/sys/netinet/cc/cc_dctcp.c +++ head/sys/netinet/cc/cc_dctcp.c @@ -184,8 +184,7 @@ static void dctcp_cb_destroy(struct cc_var *ccv) { - if (ccv->cc_data != NULL) - free(ccv->cc_data, M_dctcp); + free(ccv->cc_data, M_dctcp); } static int Index: head/sys/netinet/cc/cc_htcp.c =================================================================== --- head/sys/netinet/cc/cc_htcp.c +++ head/sys/netinet/cc/cc_htcp.c @@ -238,9 +238,7 @@ static void htcp_cb_destroy(struct cc_var *ccv) { - - if (ccv->cc_data != NULL) - free(ccv->cc_data, M_HTCP); + free(ccv->cc_data, M_HTCP); } static int Index: head/sys/netinet/cc/cc_newreno.c =================================================================== --- head/sys/netinet/cc/cc_newreno.c +++ head/sys/netinet/cc/cc_newreno.c @@ -127,9 +127,7 @@ static void newreno_cb_destroy(struct cc_var *ccv) { - - if (ccv->cc_data != NULL) - free(ccv->cc_data, M_NEWRENO); + free(ccv->cc_data, M_NEWRENO); } static void Index: head/sys/netinet/cc/cc_vegas.c =================================================================== --- head/sys/netinet/cc/cc_vegas.c +++ head/sys/netinet/cc/cc_vegas.c @@ -170,9 +170,7 @@ static void vegas_cb_destroy(struct cc_var *ccv) { - - if (ccv->cc_data != NULL) - free(ccv->cc_data, M_VEGAS); + free(ccv->cc_data, M_VEGAS); } static int Index: head/sys/netinet/tcp_subr.c =================================================================== --- head/sys/netinet/tcp_subr.c +++ head/sys/netinet/tcp_subr.c @@ -1730,10 +1730,18 @@ */ if (CC_ALGO(tp) == unload_algo) { tmpalgo = CC_ALGO(tp); - /* NewReno does not require any init. */ - CC_ALGO(tp) = &newreno_cc_algo; if (tmpalgo->cb_destroy != NULL) tmpalgo->cb_destroy(tp->ccv); + CC_DATA(tp) = NULL; + /* + * NewReno may allocate memory on + * demand for certain stateful + * configuration as needed, but is + * coded to never fail on memory + * allocation failure so it is a safe + * fallback. + */ + CC_ALGO(tp) = &newreno_cc_algo; } } INP_WUNLOCK(inp); @@ -1885,6 +1893,7 @@ /* Allow the CC algorithm to clean up after itself. */ if (CC_ALGO(tp)->cb_destroy != NULL) CC_ALGO(tp)->cb_destroy(tp->ccv); + CC_DATA(tp) = NULL; #ifdef TCP_HHOOK khelp_destroy_osd(tp->osd); Index: head/sys/netinet/tcp_usrreq.c =================================================================== --- head/sys/netinet/tcp_usrreq.c +++ head/sys/netinet/tcp_usrreq.c @@ -1729,6 +1729,7 @@ */ if (CC_ALGO(tp)->cb_destroy != NULL) CC_ALGO(tp)->cb_destroy(tp->ccv); + CC_DATA(tp) = NULL; CC_ALGO(tp) = algo; /* * If something goes pear shaped initialising the new