Skip to content

Commit d733ed4

Browse files
committed
wifi: iwlwifi: mld: don't dereference a pointer before NULL checking it
In iwl_mld_remove_link, the link->fw_id is saved at the beginning of the function so we have it after we freed the link. But the link pointer can be NULL, and is not checked when the fw_id is stored. Fix it by simply freeing the link at the end of the function. fFixes: 0e66a39f4f0e ("wifi: iwlwifi: fix potential use after free in iwl_mld_remove_link()") Reviewed-by: Johannes Berg <johannes.berg@intel.com> Link: https://patch.msgid.link/20260515151351.371f40fc6711.I6a82cfe9655564e9c5731af91c36493b26b1208e@changeid Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
1 parent 2becb38 commit d733ed4

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

  • drivers/net/wireless/intel/iwlwifi/mld

drivers/net/wireless/intel/iwlwifi/mld/link.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
22
/*
3-
* Copyright (C) 2024-2025 Intel Corporation
3+
* Copyright (C) 2024-2026 Intel Corporation
44
*/
55

66
#include "constants.h"
@@ -504,23 +504,22 @@ void iwl_mld_remove_link(struct iwl_mld *mld,
504504
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(bss_conf->vif);
505505
struct iwl_mld_link *link = iwl_mld_link_from_mac80211(bss_conf);
506506
bool is_deflink = link == &mld_vif->deflink;
507-
u8 fw_id = link->fw_id;
508507

509508
if (WARN_ON(!link || link->active))
510509
return;
511510

512511
iwl_mld_rm_link_from_fw(mld, bss_conf);
513512
/* Continue cleanup on failure */
514513

515-
if (!is_deflink)
516-
kfree_rcu(link, rcu_head);
517-
518514
RCU_INIT_POINTER(mld_vif->link[bss_conf->link_id], NULL);
519515

520-
if (WARN_ON(fw_id >= mld->fw->ucode_capa.num_links))
516+
if (WARN_ON(link->fw_id >= mld->fw->ucode_capa.num_links))
521517
return;
522518

523-
RCU_INIT_POINTER(mld->fw_id_to_bss_conf[fw_id], NULL);
519+
RCU_INIT_POINTER(mld->fw_id_to_bss_conf[link->fw_id], NULL);
520+
521+
if (!is_deflink)
522+
kfree_rcu(link, rcu_head);
524523
}
525524

526525
void iwl_mld_handle_missed_beacon_notif(struct iwl_mld *mld,

0 commit comments

Comments
 (0)