Re: [PATCH] wifi: mt76: mt7925: fix mt7925_reverse_frag0_hdr_trans() for MLO

From: Zhao Li

Date: Sun Nov 15 2026 - 14:27:56 EST


Hi Ziheng,

On Sun, Nov 15, 2026 at 04:02:39PM +0800, Ziheng Wei wrote:
> - struct mt792x_sta *msta = (struct mt792x_sta *)status->wcid;
> + struct mt792x_link_sta *mlink = (struct mt792x_link_sta *)status->wcid;
> + struct mt792x_sta *msta = mlink ? mlink->sta : NULL;

The MLO part is right, but the cast still needs a guard, and the
MT_RXD3_NORMAL_U2M check below does not provide one: it selects the
unguarded path. mt7925_mac_fill_rx() computes unicast from the same
rxd3 comparison, so every frame that gets past that check arrived
through the one branch of mt792x_rx_get_wcid() that returns the WTBL
entry as it found it:

wcid = mt76_wcid_ptr(dev, idx);
if (unicast || !wcid)
return wcid;

if (!wcid->sta)
return NULL;

Not every entry is a station link. mt792x_init_wcid() reserves index 0
for beacons and management frames and installs dev->mt76.global_wcid
there, a bare struct mt76_wcid inside struct mt76_dev, immediately
followed by the wcid[] table. For that entry, mlink->sta reads at the
offset mt792x_link_sta keeps its back pointer at, which lands in that
table, and msta->vif then dereferences whatever it found, so the header
is still built from a type-confused object. I can't say whether the
hardware reports index 0 for a header-translated unicast fragment, but
the non-unicast path in the same helper already guards its container_of()
with wcid->sta.

Doing the same here keeps the conversion valid for every entry, with
mlink and msta left uninitialized in the declarations:

if (!status->wcid || !status->wcid->sta)
return -EINVAL;

mlink = container_of(status->wcid, struct mt792x_link_sta, wcid);
msta = mlink->sta;
if (!msta || !msta->vif)
return -EINVAL;

> + link_conf = rcu_dereference(vif->link_conf[mlink->wcid.link_id]);
> + if (!sta || !link_conf)
> + return -EINVAL;

With status->wcid->sta checked above, wcid_to_sta() cannot return NULL
here, so only !link_conf needs to be tested. The per-link BSSID lookup
matches what a3ea1c309bf3 did for mt7996.

Thanks,
Zhao