[PATCH 3.2 011/115] mac80211: fix memory leak

From: Ben Hutchings
Date: Tue Apr 26 2016 - 20:45:43 EST


3.2.80-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: Sudip Mukherjee <sudip@xxxxxxxxxxxxxxx>

commit ea32f065bd3e3e09f0bcb3042f1664caf6b3e233 upstream.

On error we jumped to the error label and returned the error code but we
missed releasing sinfo.

Fixes: 5fe74014172d ("mac80211: avoid excessive stack usage in sta_info")
Reviewed-by: Julian Calaby <julian.calaby@xxxxxxxxx>
Signed-off-by: Sudip Mukherjee <sudip@xxxxxxxxxxxxxxx>
Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
[bwh: Backported to 3.2: there's no out_err label but there is another
error case that would leak sinfo]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
net/mac80211/sta_info.c | 1 +
1 file changed, 1 insertion(+)

--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -362,8 +362,10 @@ static int sta_info_finish_insert(struct
u.ap);
err = drv_sta_add(local, sdata, &sta->sta);
if (err) {
- if (!async)
+ if (!async) {
+ kfree(sinfo);
return err;
+ }
printk(KERN_DEBUG "%s: failed to add IBSS STA %pM to "
"driver (%d) - keeping it anyway.\n",
sdata->name, sta->sta.addr, err);