@@ -54,14 +54,6 @@ static void assert_key_lock(struct ieee80211_local *local)
5454 lockdep_assert_held (& local -> key_mtx );
5555}
5656
57- static struct ieee80211_sta * get_sta_for_key (struct ieee80211_key * key )
58- {
59- if (key -> sta )
60- return & key -> sta -> sta ;
61-
62- return NULL ;
63- }
64-
6557static void increment_tailroom_need_count (struct ieee80211_sub_if_data * sdata )
6658{
6759 /*
@@ -95,7 +87,7 @@ static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
9587static int ieee80211_key_enable_hw_accel (struct ieee80211_key * key )
9688{
9789 struct ieee80211_sub_if_data * sdata ;
98- struct ieee80211_sta * sta ;
90+ struct sta_info * sta ;
9991 int ret ;
10092
10193 might_sleep ();
@@ -105,7 +97,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
10597
10698 assert_key_lock (key -> local );
10799
108- sta = get_sta_for_key ( key ) ;
100+ sta = key -> sta ;
109101
110102 /*
111103 * If this is a per-STA GTK, check if it
@@ -115,6 +107,9 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
115107 !(key -> local -> hw .flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK ))
116108 goto out_unsupported ;
117109
110+ if (sta && !sta -> uploaded )
111+ goto out_unsupported ;
112+
118113 sdata = key -> sdata ;
119114 if (sdata -> vif .type == NL80211_IFTYPE_AP_VLAN ) {
120115 /*
@@ -125,7 +120,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
125120 goto out_unsupported ;
126121 }
127122
128- ret = drv_set_key (key -> local , SET_KEY , sdata , sta , & key -> conf );
123+ ret = drv_set_key (key -> local , SET_KEY , sdata ,
124+ sta ? & sta -> sta : NULL , & key -> conf );
129125
130126 if (!ret ) {
131127 key -> flags |= KEY_FLAG_UPLOADED_TO_HARDWARE ;
@@ -144,7 +140,8 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
144140 if (ret != - ENOSPC && ret != - EOPNOTSUPP )
145141 wiphy_err (key -> local -> hw .wiphy ,
146142 "failed to set key (%d, %pM) to hardware (%d)\n" ,
147- key -> conf .keyidx , sta ? sta -> addr : bcast_addr , ret );
143+ key -> conf .keyidx ,
144+ sta ? sta -> sta .addr : bcast_addr , ret );
148145
149146 out_unsupported :
150147 switch (key -> conf .cipher ) {
@@ -163,7 +160,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
163160static void ieee80211_key_disable_hw_accel (struct ieee80211_key * key )
164161{
165162 struct ieee80211_sub_if_data * sdata ;
166- struct ieee80211_sta * sta ;
163+ struct sta_info * sta ;
167164 int ret ;
168165
169166 might_sleep ();
@@ -176,7 +173,7 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
176173 if (!(key -> flags & KEY_FLAG_UPLOADED_TO_HARDWARE ))
177174 return ;
178175
179- sta = get_sta_for_key ( key ) ;
176+ sta = key -> sta ;
180177 sdata = key -> sdata ;
181178
182179 if (!((key -> conf .flags & IEEE80211_KEY_FLAG_GENERATE_MMIC ) ||
@@ -185,12 +182,13 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
185182 increment_tailroom_need_count (sdata );
186183
187184 ret = drv_set_key (key -> local , DISABLE_KEY , sdata ,
188- sta , & key -> conf );
185+ sta ? & sta -> sta : NULL , & key -> conf );
189186
190187 if (ret )
191188 wiphy_err (key -> local -> hw .wiphy ,
192189 "failed to remove key (%d, %pM) from hardware (%d)\n" ,
193- key -> conf .keyidx , sta ? sta -> addr : bcast_addr , ret );
190+ key -> conf .keyidx ,
191+ sta ? sta -> sta .addr : bcast_addr , ret );
194192
195193 key -> flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE ;
196194}
0 commit comments