From 73651ee6396c499ccb59ebc84c9274db01ed026d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 25 Feb 2008 16:27:47 +0100 Subject: mac80211: split sta_info_add sta_info_add() has two functions: allocating a station info structure and inserting it into the hash table/list. Splitting these two functions allows allocating with GFP_KERNEL in many places instead of GFP_ATOMIC which is now required by the RCU protection. Additionally, in many places RCU protection is now no longer needed at all because between sta_info_alloc() and sta_info_insert() the caller owns the structure. This fixes a few race conditions with setting initial flags and similar, but not all (see comments in ieee80211_sta.c and cfg.c). More documentation on the existing races will be in a follow-up patch. Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- net/mac80211/sta_info.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'net/mac80211/sta_info.h') diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 787124c253a..3f788228eef 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -283,12 +283,19 @@ struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr); struct sta_info *sta_info_get_by_idx(struct ieee80211_local *local, int idx, struct net_device *dev); /* - * Add a new STA info, must be under RCU read lock - * because otherwise the returned reference isn't - * necessarily valid long enough. + * Create a new STA info, caller owns returned structure + * until sta_info_insert(). */ -struct sta_info *sta_info_add(struct ieee80211_sub_if_data *sdata, - u8 *addr); +struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, + u8 *addr, gfp_t gfp); +/* + * Insert STA info into hash table/list, returns zero or a + * -EEXIST if (if the same MAC address is already present). + * + * Calling this without RCU protection makes the caller + * relinquish its reference to @sta. + */ +int sta_info_insert(struct sta_info *sta); /* * Unlink a STA info from the hash table/list. * This can NULL the STA pointer if somebody else -- cgit v1.2.3