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 <johnfwhitmore@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
John Whitmore 2018-09-26 20:17:04 +01:00 committed by Greg Kroah-Hartman
parent 12f34f81ba
commit daf9a56cbb
1 changed files with 5 additions and 0 deletions

View File

@ -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);