Skip to content

Commit

Permalink
ath10k: use dedicated list iterator variable
Browse files Browse the repository at this point in the history
To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
  • Loading branch information
Jakob-Koschel committed Mar 28, 2022
1 parent 0d26e98 commit d4ae254
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions drivers/net/wireless/ath/ath10k/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static int ath10k_clear_vdev_key(struct ath10k_vif *arvif,
struct ieee80211_key_conf *key)
{
struct ath10k *ar = arvif->ar;
struct ath10k_peer *peer;
struct ath10k_peer *peer = NULL, *iter;
u8 addr[ETH_ALEN];
int first_errno = 0;
int ret;
Expand All @@ -493,21 +493,23 @@ static int ath10k_clear_vdev_key(struct ath10k_vif *arvif,
*/
spin_lock_bh(&ar->data_lock);
i = 0;
list_for_each_entry(peer, &ar->peers, list) {
for (i = 0; i < ARRAY_SIZE(peer->keys); i++) {
if (peer->keys[i] == key) {
ether_addr_copy(addr, peer->addr);
peer->keys[i] = NULL;
list_for_each_entry(iter, &ar->peers, list) {
for (i = 0; i < ARRAY_SIZE(iter->keys); i++) {
if (iter->keys[i] == key) {
ether_addr_copy(addr, iter->addr);
iter->keys[i] = NULL;
break;
}
}

if (i < ARRAY_SIZE(peer->keys))
if (i < ARRAY_SIZE(iter->keys)) {
peer = iter;
break;
}
}
spin_unlock_bh(&ar->data_lock);

if (i == ARRAY_SIZE(peer->keys))
if (!peer)
break;
/* key flags are not required to delete the key */
ret = ath10k_install_key(arvif, key, DISABLE_KEY, addr, flags);
Expand Down

0 comments on commit d4ae254

Please sign in to comment.