From cc834d24c6a1c545ecdd3f8f9891d6720cd054a9 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 17 Sep 2018 02:34:16 +0000 Subject: [PATCH] fix memory leaks in ieee80211_add_ess() ok stsp@ phessler@ --- sys/net80211/ieee80211_node.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index bb0eceda9b8..0c6822a77f8 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.c,v 1.150 2018/09/11 19:25:54 phessler Exp $ */ +/* $OpenBSD: ieee80211_node.c,v 1.151 2018/09/17 02:34:16 jsg Exp $ */ /* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */ /*- @@ -379,8 +379,10 @@ ieee80211_add_ess(struct ieee80211com *ic, struct ieee80211_join *join) if (join->i_flags & IEEE80211_JOIN_WPA) { if (join->i_wpaparams.i_enabled) { - if (!(ic->ic_caps & IEEE80211_C_RSN)) + if (!(ic->ic_caps & IEEE80211_C_RSN)) { + free(ess, M_DEVBUF, sizeof(*ess)); return ENODEV; + } ieee80211_ess_setwpaparms(ess, &join->i_wpaparams); if (join->i_flags & IEEE80211_JOIN_WPAPSK) { @@ -395,8 +397,10 @@ ieee80211_add_ess(struct ieee80211com *ic, struct ieee80211_join *join) } } else if (join->i_flags & IEEE80211_JOIN_NWKEY) { if (join->i_nwkey.i_wepon) { - if (!(ic->ic_caps & IEEE80211_C_WEP)) + if (!(ic->ic_caps & IEEE80211_C_WEP)) { + free(ess, M_DEVBUF, sizeof(*ess)); return ENODEV; + } ieee80211_ess_setnwkeys(ess, &join->i_nwkey); ieee80211_ess_clear_wpa(ess); } else { -- 2.20.1