]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
carl9170: tx: fix an incorrect use of list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Mon, 28 Mar 2022 12:28:20 +0000 (20:28 +0800)
committerKalle Valo <quic_kvalo@quicinc.com>
Mon, 2 May 2022 14:00:46 +0000 (17:00 +0300)
If the previous list_for_each_entry_continue_rcu() don't exit early
(no goto hit inside the loop), the iterator 'cvif' after the loop
will be a bogus pointer to an invalid structure object containing
the HEAD (&ar->vif_list). As a result, the use of 'cvif' after that
will lead to a invalid memory access (i.e., 'cvif->id': the invalid
pointer dereference when return back to/after the callsite in the
carl9170_update_beacon()).

The original intention should have been to return the valid 'cvif'
when found in list, NULL otherwise. So just return NULL when no
entry found, to fix this bug.

Cc: stable@vger.kernel.org
Fixes: 1f1d9654e183c ("carl9170: refactor carl9170_update_beacon")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220328122820.1004-1-xiam0nd.tong@gmail.com
drivers/net/wireless/ath/carl9170/tx.c

index 1b76f4434c069c10df4475d9b048a3362f453534..791f9f120af3a9bacf411175a032752b68103bc8 100644 (file)
@@ -1558,6 +1558,9 @@ static struct carl9170_vif_info *carl9170_pick_beaconing_vif(struct ar9170 *ar)
                                        goto out;
                        }
                } while (ar->beacon_enabled && i--);
+
+               /* no entry found in list */
+               return NULL;
        }
 
 out: