Skip to content
/ linux Public

Commit b4d46b4

Browse files
Bitterblue SmithSasha Levin
authored andcommitted
wifi: rtw88: Fix inadvertent sharing of struct ieee80211_supported_band data
[ Upstream commit fcac0f2 ] 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 0ae3639 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9b54180 commit b4d46b4

File tree

1 file changed

+29
-5
lines changed
  • drivers/net/wireless/realtek/rtw88

1 file changed

+29
-5
lines changed

drivers/net/wireless/realtek/rtw88/main.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,16 +1629,41 @@ static u16 rtw_get_max_scan_ie_len(struct rtw_dev *rtwdev)
16291629
return len;
16301630
}
16311631

1632+
static struct ieee80211_supported_band *
1633+
rtw_sband_dup(struct rtw_dev *rtwdev,
1634+
const struct ieee80211_supported_band *sband)
1635+
{
1636+
struct ieee80211_supported_band *dup;
1637+
1638+
dup = devm_kmemdup(rtwdev->dev, sband, sizeof(*sband), GFP_KERNEL);
1639+
if (!dup)
1640+
return NULL;
1641+
1642+
dup->channels = devm_kmemdup_array(rtwdev->dev, sband->channels,
1643+
sband->n_channels,
1644+
sizeof(*sband->channels),
1645+
GFP_KERNEL);
1646+
if (!dup->channels)
1647+
return NULL;
1648+
1649+
dup->bitrates = devm_kmemdup_array(rtwdev->dev, sband->bitrates,
1650+
sband->n_bitrates,
1651+
sizeof(*sband->bitrates),
1652+
GFP_KERNEL);
1653+
if (!dup->bitrates)
1654+
return NULL;
1655+
1656+
return dup;
1657+
}
1658+
16321659
static void rtw_set_supported_band(struct ieee80211_hw *hw,
16331660
const struct rtw_chip_info *chip)
16341661
{
16351662
struct ieee80211_supported_band *sband;
16361663
struct rtw_dev *rtwdev = hw->priv;
1637-
struct device *dev = rtwdev->dev;
16381664

16391665
if (chip->band & RTW_BAND_2G) {
1640-
sband = devm_kmemdup(dev, &rtw_band_2ghz, sizeof(*sband),
1641-
GFP_KERNEL);
1666+
sband = rtw_sband_dup(rtwdev, &rtw_band_2ghz);
16421667
if (!sband)
16431668
goto err_out;
16441669
if (chip->ht_supported)
@@ -1647,8 +1672,7 @@ static void rtw_set_supported_band(struct ieee80211_hw *hw,
16471672
}
16481673

16491674
if (chip->band & RTW_BAND_5G) {
1650-
sband = devm_kmemdup(dev, &rtw_band_5ghz, sizeof(*sband),
1651-
GFP_KERNEL);
1675+
sband = rtw_sband_dup(rtwdev, &rtw_band_5ghz);
16521676
if (!sband)
16531677
goto err_out;
16541678
if (chip->ht_supported)

0 commit comments

Comments
 (0)