From: John Whitmore Date: Wed, 26 Sep 2018 19:17:04 +0000 (+0100) Subject: staging:rtl8192u: Remove potential memory leak X-Git-Tag: v5.15~7699^2~244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=daf9a56cbb791865db751d97c570d90b9e0aed20;p=platform%2Fkernel%2Flinux-starfive.git staging:rtl8192u: Remove potential memory leak Add call to ieee80211_networks_free() to avoid potential memory leak if allocation of pHTInfo fails. If the third allocation fails only the first successful allocation is freed, not the second. Signed-off-by: John Whitmore Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index 90a097f..aada077 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -159,6 +159,11 @@ struct net_device *alloc_ieee80211(int sizeof_priv) ieee->pHTInfo = kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL); if (ieee->pHTInfo == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n"); + + /* By this point in code ieee80211_networks_allocate() has been + * successfully called so the memory allocated should be freed + */ + ieee80211_networks_free(ieee); goto failed; } HTUpdateDefaultSetting(ieee);