* [PATCH v2 wireless 2/3] wifi: rt2x00: replace open-coded IE search with cfg80211_find_ie()
@ 2026-10-26 22:32 Tristan Madani
2026-10-27 16:26 ` Stanislaw Gruszka
0 siblings, 1 reply; 2+ messages in thread
From: Tristan Madani @ 2026-10-26 22:32 UTC (permalink / raw)
To: Johannes Berg, Christian Lamparter, Stanislaw Gruszka
Cc: Ivo van Doorn, John W . Linville, Kees Cook, linux-wireless,
linux-kernel, stable, tristan
rt2x00lib_find_ie() open-codes the IE search that cfg80211_find_ie()
already provides. Replace the hand-rolled function with
cfg80211_find_ie() at the single call site.
Fixes: 1c0bcf89d85cc ("rt2x00: Add autowake support for USB hardware")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
.../net/wireless/ralink/rt2x00/rt2x00dev.c | 30 +++++--------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
index 4d94b7062f440..921383a630bf2 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
@@ -557,26 +557,6 @@ void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status)
}
EXPORT_SYMBOL_GPL(rt2x00lib_txdone_noinfo);
-static u8 *rt2x00lib_find_ie(u8 *data, unsigned int len, u8 ie)
-{
- struct ieee80211_mgmt *mgmt = (void *)data;
- u8 *pos, *end;
-
- pos = (u8 *)mgmt->u.beacon.variable;
- end = data + len;
- while (pos < end) {
- if (pos + 2 + pos[1] > end)
- return NULL;
-
- if (pos[0] == ie)
- return pos;
-
- pos += 2 + pos[1];
- }
-
- return NULL;
-}
-
static void rt2x00lib_sleep(struct work_struct *work)
{
struct rt2x00_dev *rt2x00dev =
@@ -642,9 +622,10 @@ static void rt2x00lib_rxdone_check_ps(struct rt2x00_dev *rt2x00dev,
struct sk_buff *skb,
struct rxdone_entry_desc *rxdesc)
{
- struct ieee80211_hdr *hdr = (void *) skb->data;
+ struct ieee80211_hdr *hdr = (void *)skb->data;
+ struct ieee80211_mgmt *mgmt = (void *)skb->data;
struct ieee80211_tim_ie *tim_ie;
- u8 *tim;
+ const u8 *tim;
u8 tim_len;
bool cam;
@@ -666,7 +647,10 @@ static void rt2x00lib_rxdone_check_ps(struct rt2x00_dev *rt2x00dev,
rt2x00dev->last_beacon = jiffies;
- tim = rt2x00lib_find_ie(skb->data, skb->len - FCS_LEN, WLAN_EID_TIM);
+ tim = cfg80211_find_ie(WLAN_EID_TIM, mgmt->u.beacon.variable,
+ (skb->len - FCS_LEN) -
+ offsetof(struct ieee80211_mgmt,
+ u.beacon.variable));
if (!tim)
return;
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2 wireless 2/3] wifi: rt2x00: replace open-coded IE search with cfg80211_find_ie()
2026-10-26 22:32 [PATCH v2 wireless 2/3] wifi: rt2x00: replace open-coded IE search with cfg80211_find_ie() Tristan Madani
@ 2026-10-27 16:26 ` Stanislaw Gruszka
0 siblings, 0 replies; 2+ messages in thread
From: Stanislaw Gruszka @ 2026-10-27 16:26 UTC (permalink / raw)
To: Tristan Madani
Cc: Johannes Berg, Christian Lamparter, Ivo van Doorn,
John W . Linville, Kees Cook, linux-wireless, linux-kernel,
stable, tristan
On Mon, Oct 26, 2026 at 10:32:13PM +0000, Tristan Madani wrote:
> rt2x00lib_find_ie() open-codes the IE search that cfg80211_find_ie()
> already provides. Replace the hand-rolled function with
> cfg80211_find_ie() at the single call site.
>
> Fixes: 1c0bcf89d85cc ("rt2x00: Add autowake support for USB hardware")
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
> ---
> .../net/wireless/ralink/rt2x00/rt2x00dev.c | 30 +++++--------------
> 1 file changed, 7 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
> index 4d94b7062f440..921383a630bf2 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
> @@ -557,26 +557,6 @@ void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status)
> }
> EXPORT_SYMBOL_GPL(rt2x00lib_txdone_noinfo);
>
> -static u8 *rt2x00lib_find_ie(u8 *data, unsigned int len, u8 ie)
> -{
> - struct ieee80211_mgmt *mgmt = (void *)data;
> - u8 *pos, *end;
> -
> - pos = (u8 *)mgmt->u.beacon.variable;
> - end = data + len;
> - while (pos < end) {
> - if (pos + 2 + pos[1] > end)
> - return NULL;
> -
> - if (pos[0] == ie)
> - return pos;
> -
> - pos += 2 + pos[1];
> - }
> -
> - return NULL;
> -}
> -
> static void rt2x00lib_sleep(struct work_struct *work)
> {
> struct rt2x00_dev *rt2x00dev =
> @@ -642,9 +622,10 @@ static void rt2x00lib_rxdone_check_ps(struct rt2x00_dev *rt2x00dev,
> struct sk_buff *skb,
> struct rxdone_entry_desc *rxdesc)
> {
> - struct ieee80211_hdr *hdr = (void *) skb->data;
> + struct ieee80211_hdr *hdr = (void *)skb->data;
> + struct ieee80211_mgmt *mgmt = (void *)skb->data;
> struct ieee80211_tim_ie *tim_ie;
> - u8 *tim;
> + const u8 *tim;
> u8 tim_len;
> bool cam;
>
> @@ -666,7 +647,10 @@ static void rt2x00lib_rxdone_check_ps(struct rt2x00_dev *rt2x00dev,
>
> rt2x00dev->last_beacon = jiffies;
>
> - tim = rt2x00lib_find_ie(skb->data, skb->len - FCS_LEN, WLAN_EID_TIM);
> + tim = cfg80211_find_ie(WLAN_EID_TIM, mgmt->u.beacon.variable,
> + (skb->len - FCS_LEN) -
> + offsetof(struct ieee80211_mgmt,
> + u.beacon.variable));
> if (!tim)
> return;
>
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-27 16:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 22:32 [PATCH v2 wireless 2/3] wifi: rt2x00: replace open-coded IE search with cfg80211_find_ie() Tristan Madani
2026-10-27 16:26 ` Stanislaw Gruszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®