Skip to content

Commit 27ec3c5

Browse files
saschahauerKalle Valo
authored andcommitted
wifi: mwifiex: duplicate static structs used in driver instances
mwifiex_band_2ghz and mwifiex_band_5ghz are statically allocated, but used and modified in driver instances. Duplicate them before using them in driver instances so that different driver instances do not influence each other. This was observed on a board which has one PCIe and one SDIO mwifiex adapter. It blew up in mwifiex_setup_ht_caps(). This was called with the statically allocated struct which is modified in this function. Cc: [email protected] Fixes: d6bffe8 ("mwifiex: support for creation of AP interface") Signed-off-by: Sascha Hauer <[email protected]> Reviewed-by: Francesco Dolcini <[email protected]> Acked-by: Brian Norris <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://patch.msgid.link/20240809-mwifiex-duplicate-static-structs-v1-1-6837b903b1a4@pengutronix.de
1 parent e37a918 commit 27ec3c5

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

drivers/net/wireless/marvell/mwifiex/cfg80211.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,11 +4363,27 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
43634363
if (ISSUPP_ADHOC_ENABLED(adapter->fw_cap_info))
43644364
wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
43654365

4366-
wiphy->bands[NL80211_BAND_2GHZ] = &mwifiex_band_2ghz;
4367-
if (adapter->config_bands & BAND_A)
4368-
wiphy->bands[NL80211_BAND_5GHZ] = &mwifiex_band_5ghz;
4369-
else
4366+
wiphy->bands[NL80211_BAND_2GHZ] = devm_kmemdup(adapter->dev,
4367+
&mwifiex_band_2ghz,
4368+
sizeof(mwifiex_band_2ghz),
4369+
GFP_KERNEL);
4370+
if (!wiphy->bands[NL80211_BAND_2GHZ]) {
4371+
ret = -ENOMEM;
4372+
goto err;
4373+
}
4374+
4375+
if (adapter->config_bands & BAND_A) {
4376+
wiphy->bands[NL80211_BAND_5GHZ] = devm_kmemdup(adapter->dev,
4377+
&mwifiex_band_5ghz,
4378+
sizeof(mwifiex_band_5ghz),
4379+
GFP_KERNEL);
4380+
if (!wiphy->bands[NL80211_BAND_5GHZ]) {
4381+
ret = -ENOMEM;
4382+
goto err;
4383+
}
4384+
} else {
43704385
wiphy->bands[NL80211_BAND_5GHZ] = NULL;
4386+
}
43714387

43724388
if (adapter->drcs_enabled && ISSUPP_DRCS_ENABLED(adapter->fw_cap_info))
43734389
wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta_drcs;
@@ -4461,8 +4477,7 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
44614477
if (ret < 0) {
44624478
mwifiex_dbg(adapter, ERROR,
44634479
"%s: wiphy_register failed: %d\n", __func__, ret);
4464-
wiphy_free(wiphy);
4465-
return ret;
4480+
goto err;
44664481
}
44674482

44684483
if (!adapter->regd) {
@@ -4504,4 +4519,9 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
45044519

45054520
adapter->wiphy = wiphy;
45064521
return ret;
4522+
4523+
err:
4524+
wiphy_free(wiphy);
4525+
4526+
return ret;
45074527
}

0 commit comments

Comments
 (0)