mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
wifi: rtw88: Fix inadvertent sharing of struct ieee80211_supported_band data
Internally wiphy writes to individual channels in this structure,
so we must not share one static definition of channel list between
multiple device instances, because that causes hard to debug
breakage.
For example, with two rtw88 driven devices in the system, channel
information may get incoherent, preventing channel use.
Copied from commit 0ae36391c8 ("wifi: rtw89: Fix inadverent sharing
of struct ieee80211_supported_band data").
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/e94ad653-2b6d-4284-a33c-8c694f88955b@gmail.com
This commit is contained in:
parent
2ba12401cc
commit
fcac0f23d4
|
|
@ -1661,16 +1661,41 @@ static u16 rtw_get_max_scan_ie_len(struct rtw_dev *rtwdev)
|
|||
return len;
|
||||
}
|
||||
|
||||
static struct ieee80211_supported_band *
|
||||
rtw_sband_dup(struct rtw_dev *rtwdev,
|
||||
const struct ieee80211_supported_band *sband)
|
||||
{
|
||||
struct ieee80211_supported_band *dup;
|
||||
|
||||
dup = devm_kmemdup(rtwdev->dev, sband, sizeof(*sband), GFP_KERNEL);
|
||||
if (!dup)
|
||||
return NULL;
|
||||
|
||||
dup->channels = devm_kmemdup_array(rtwdev->dev, sband->channels,
|
||||
sband->n_channels,
|
||||
sizeof(*sband->channels),
|
||||
GFP_KERNEL);
|
||||
if (!dup->channels)
|
||||
return NULL;
|
||||
|
||||
dup->bitrates = devm_kmemdup_array(rtwdev->dev, sband->bitrates,
|
||||
sband->n_bitrates,
|
||||
sizeof(*sband->bitrates),
|
||||
GFP_KERNEL);
|
||||
if (!dup->bitrates)
|
||||
return NULL;
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
static void rtw_set_supported_band(struct ieee80211_hw *hw,
|
||||
const struct rtw_chip_info *chip)
|
||||
{
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct device *dev = rtwdev->dev;
|
||||
|
||||
if (chip->band & RTW_BAND_2G) {
|
||||
sband = devm_kmemdup(dev, &rtw_band_2ghz, sizeof(*sband),
|
||||
GFP_KERNEL);
|
||||
sband = rtw_sband_dup(rtwdev, &rtw_band_2ghz);
|
||||
if (!sband)
|
||||
goto err_out;
|
||||
if (chip->ht_supported)
|
||||
|
|
@ -1679,8 +1704,7 @@ static void rtw_set_supported_band(struct ieee80211_hw *hw,
|
|||
}
|
||||
|
||||
if (chip->band & RTW_BAND_5G) {
|
||||
sband = devm_kmemdup(dev, &rtw_band_5ghz, sizeof(*sband),
|
||||
GFP_KERNEL);
|
||||
sband = rtw_sband_dup(rtwdev, &rtw_band_5ghz);
|
||||
if (!sband)
|
||||
goto err_out;
|
||||
if (chip->ht_supported)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user