Skip to content

Commit 3194eb0

Browse files
jmberg-intelksacilotto
authored andcommitted
mac80211: free sta in sta_info_insert_finish() on errors
BugLink: https://bugs.launchpad.net/bugs/1908561 commit 7bc40ae upstream. If sta_info_insert_finish() fails, we currently keep the station around and free it only in the caller, but there's only one such caller and it always frees it immediately. As syzbot found, another consequence of this split is that we can put things that sleep only into __cleanup_single_sta() and not in sta_info_free(), but this is the only place that requires such of sta_info_free() now. Change this to free the station in sta_info_insert_finish(), in which case we can still sleep. This will also let us unify the cleanup code later. Cc: [email protected] Fixes: dcd479e ("mac80211: always wind down STA state") Reported-by: [email protected] Reported-by: [email protected] Reported-by: [email protected] Reported-by: [email protected] Reported-by: [email protected] Reported-by: [email protected] Link: https://lore.kernel.org/r/20201112112201.ee6b397b9453.I9c31d667a0ea2151441cc64ed6613d36c18a48e0@changeid Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Ian May <[email protected]>
1 parent bfb0593 commit 3194eb0

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

net/mac80211/sta_info.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
688688
out_drop_sta:
689689
local->num_sta--;
690690
synchronize_net();
691-
__cleanup_single_sta(sta);
691+
cleanup_single_sta(sta);
692692
out_err:
693693
mutex_unlock(&local->sta_mtx);
694694
kfree(sinfo);
@@ -707,19 +707,13 @@ int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU)
707707

708708
err = sta_info_insert_check(sta);
709709
if (err) {
710+
sta_info_free(local, sta);
710711
mutex_unlock(&local->sta_mtx);
711712
rcu_read_lock();
712-
goto out_free;
713+
return err;
713714
}
714715

715-
err = sta_info_insert_finish(sta);
716-
if (err)
717-
goto out_free;
718-
719-
return 0;
720-
out_free:
721-
sta_info_free(local, sta);
722-
return err;
716+
return sta_info_insert_finish(sta);
723717
}
724718

725719
int sta_info_insert(struct sta_info *sta)

0 commit comments

Comments
 (0)