mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
wifi: rtw88: Use devm_kmemdup() in rtw_set_supported_band()
Simplify the code by using device managed memory allocations.
This also fixes a memory leak in rtw_register_hw(). The supported bands
were not freed in the error path.
Copied from commit 145df52a86 ("wifi: rtw89: Convert
rtw89_core_set_supported_band to use devm_*").
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/1aa7fdef-2d5b-4a31-a4e9-fac8257ed30d@gmail.com
This commit is contained in:
parent
0177aa828d
commit
2ba12401cc
|
|
@ -1664,11 +1664,13 @@ static u16 rtw_get_max_scan_ie_len(struct rtw_dev *rtwdev)
|
|||
static void rtw_set_supported_band(struct ieee80211_hw *hw,
|
||||
const struct rtw_chip_info *chip)
|
||||
{
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct rtw_dev *rtwdev = hw->priv;
|
||||
struct device *dev = rtwdev->dev;
|
||||
|
||||
if (chip->band & RTW_BAND_2G) {
|
||||
sband = kmemdup(&rtw_band_2ghz, sizeof(*sband), GFP_KERNEL);
|
||||
sband = devm_kmemdup(dev, &rtw_band_2ghz, sizeof(*sband),
|
||||
GFP_KERNEL);
|
||||
if (!sband)
|
||||
goto err_out;
|
||||
if (chip->ht_supported)
|
||||
|
|
@ -1677,7 +1679,8 @@ static void rtw_set_supported_band(struct ieee80211_hw *hw,
|
|||
}
|
||||
|
||||
if (chip->band & RTW_BAND_5G) {
|
||||
sband = kmemdup(&rtw_band_5ghz, sizeof(*sband), GFP_KERNEL);
|
||||
sband = devm_kmemdup(dev, &rtw_band_5ghz, sizeof(*sband),
|
||||
GFP_KERNEL);
|
||||
if (!sband)
|
||||
goto err_out;
|
||||
if (chip->ht_supported)
|
||||
|
|
@ -1693,13 +1696,6 @@ static void rtw_set_supported_band(struct ieee80211_hw *hw,
|
|||
rtw_err(rtwdev, "failed to set supported band\n");
|
||||
}
|
||||
|
||||
static void rtw_unset_supported_band(struct ieee80211_hw *hw,
|
||||
const struct rtw_chip_info *chip)
|
||||
{
|
||||
kfree(hw->wiphy->bands[NL80211_BAND_2GHZ]);
|
||||
kfree(hw->wiphy->bands[NL80211_BAND_5GHZ]);
|
||||
}
|
||||
|
||||
static void rtw_vif_smps_iter(void *data, u8 *mac,
|
||||
struct ieee80211_vif *vif)
|
||||
{
|
||||
|
|
@ -2323,10 +2319,7 @@ EXPORT_SYMBOL(rtw_register_hw);
|
|||
|
||||
void rtw_unregister_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw)
|
||||
{
|
||||
const struct rtw_chip_info *chip = rtwdev->chip;
|
||||
|
||||
ieee80211_unregister_hw(hw);
|
||||
rtw_unset_supported_band(hw, chip);
|
||||
rtw_debugfs_deinit(rtwdev);
|
||||
rtw_led_deinit(rtwdev);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user