Skip to content

mt76: mt76_vif_phy() return hw->priv when chanctx is absent - #16

Open
EdinsonMoreno wants to merge 1 commit into
hmtheboy154:backportfrom
EdinsonMoreno:fix/mt76-vif-phy-null-chanctx
Open

mt76: mt76_vif_phy() return hw->priv when chanctx is absent#16
EdinsonMoreno wants to merge 1 commit into
hmtheboy154:backportfrom
EdinsonMoreno:fix/mt76-vif-phy-null-chanctx

Conversation

@EdinsonMoreno

Copy link
Copy Markdown

Problem

On single-radio setups or during early STA association events, mlink->ctx may not be assigned yet. mt76_vif_phy() currently returns NULL in this case, which propagates as -EINVAL (-22) to any caller that doesn't explicitly guard against NULL, causing station insertion to fail:

wlp3s0: failed to insert STA entry for the AP (error -22)

Reported by @oswystk15662 in issue #11: #11 (comment)

Fix

Return hw->priv (the primary PHY) instead of NULL when mlink->ctx == NULL. This matches the behavior already implemented for kernels >= 6.15 with !hw->wiphy->n_radio:

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0))
    if (!hw->wiphy->n_radio)
        return hw->priv;
#endif

The same logic applies here: on a single-radio device with no chanctx assigned yet, hw->priv is always the correct PHY to return.

Tested on

  • Hardware: MT7902 (PCI 14c3:7902)
  • Kernel: 7.0.9 (Fedora 44)
  • WiFi association completes successfully after this fix

Note

This fix was verified independently by @oswystk15662 (Ubuntu 22.04, kernel 6.8.0) as resolving the -22 error on their setup.

On single-radio setups or during early STA association events,
mlink->ctx may not be assigned yet. Returning NULL in that case
propagates as -EINVAL (-22) to callers such as sta_add, causing
station insertion to fail with:

  wlp3s0: failed to insert STA entry for the AP (error -22)

Return hw->priv (the primary PHY) instead, matching the existing
behavior already applied for kernels >= 6.15 with n_radio == 0.

Reported-by: oswystk15662 <hmtheboy154#11 (comment)>
@Erwin-Iosef

Copy link
Copy Markdown

Thanks for the work, but if this isn't for a specific version of the kernel if I understand it right, shouldn't this be submitted upstream as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants