[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251105-aheev-uninitialized-free-attr-wireless-v1-1-6c850a4a952a@gmail.com>
Date: Wed, 05 Nov 2025 17:20:01 +0530
From: Ally Heev <allyheev@...il.com>
To: Miri Korenblit <miriam.rachel.korenblit@...el.com>
Cc: linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
Dan Carpenter <dan.carpenter@...aro.org>, Ally Heev <allyheev@...il.com>
Subject: [PATCH] net: wireless: fix uninitialized pointers with free attr
Uninitialized pointers with `__free` attribute can cause undefined
behaviour as the memory assigned(randomly) to the pointer is freed
automatically when the pointer goes out of scope
wireless doesn't have any bugs related to this as of now, but
it is better to initialize and assign pointers with `__free` attr
in one statement to ensure proper scope-based cleanup
Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
Signed-off-by: Ally Heev <allyheev@...il.com>
---
drivers/net/wireless/intel/iwlwifi/fw/uefi.c | 6 +++---
drivers/net/wireless/intel/iwlwifi/mld/d3.c | 16 ++++++----------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
index 4ae4d215e633e0d51194d818d479349e7c502201..7fcd76f2ef8e373f16c09ed16ade1ef16ccf6bed 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
@@ -818,11 +818,11 @@ int iwl_uefi_get_dsbr(struct iwl_fw_runtime *fwrt, u32 *value)
int iwl_uefi_get_phy_filters(struct iwl_fw_runtime *fwrt)
{
- struct uefi_cnv_wpfc_data *data __free(kfree);
struct iwl_phy_specific_cfg *filters = &fwrt->phy_filters;
- data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WPFC_NAME,
- "WPFC", sizeof(*data), NULL);
+ struct uefi_cnv_wpfc_data *data __free(kfree) = iwl_uefi_get_verified_variable(fwrt->trans,
+ IWL_UEFI_WPFC_NAME, "WPFC", sizeof(*data), NULL);
+
if (IS_ERR(data))
return -EINVAL;
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/d3.c b/drivers/net/wireless/intel/iwlwifi/mld/d3.c
index 1d4282a21f09e0f90a52dc02c8287ecc0e0fafe1..515728b8cacf4004a121183cc93ab28b17b3bdc8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/d3.c
@@ -592,7 +592,6 @@ iwl_mld_handle_wowlan_info_notif(struct iwl_mld *mld,
struct iwl_rx_packet *pkt)
{
const struct iwl_wowlan_info_notif *notif;
- struct iwl_wowlan_info_notif *converted_notif __free(kfree) = NULL;
u32 len = iwl_rx_packet_payload_len(pkt);
int wowlan_info_ver = iwl_fw_lookup_notif_ver(mld->fw,
PROT_OFFLOAD_GROUP,
@@ -609,10 +608,10 @@ iwl_mld_handle_wowlan_info_notif(struct iwl_mld *mld,
5))
return true;
- converted_notif = kzalloc(struct_size(converted_notif,
- mlo_gtks,
- notif_v5->num_mlo_link_keys),
- GFP_ATOMIC);
+ struct iwl_wowlan_info_notif *converted_notif __free(kfree) =
+ kzalloc(struct_size(converted_notif, mlo_gtks, notif_v5->num_mlo_link_keys),
+ GFP_ATOMIC);
+
if (!converted_notif) {
IWL_ERR(mld,
"Failed to allocate memory for converted wowlan_info_notif\n");
@@ -996,8 +995,6 @@ static void iwl_mld_mlo_rekey(struct iwl_mld *mld,
struct iwl_mld_wowlan_status *wowlan_status,
struct ieee80211_vif *vif)
{
- struct iwl_mld_old_mlo_keys *old_keys __free(kfree) = NULL;
-
IWL_DEBUG_WOWLAN(mld, "Num of MLO Keys: %d\n", wowlan_status->num_mlo_keys);
if (!wowlan_status->num_mlo_keys)
@@ -1785,7 +1782,8 @@ iwl_mld_send_proto_offload(struct iwl_mld *mld,
struct ieee80211_vif *vif,
u8 ap_sta_id)
{
- struct iwl_proto_offload_cmd_v4 *cmd __free(kfree);
+ struct iwl_proto_offload_cmd_v4 *cmd __free(kfree) = kzalloc(sizeof(*cmd),
+ GFP_KERNEL);
struct iwl_host_cmd hcmd = {
.id = PROT_OFFLOAD_CONFIG_CMD,
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
@@ -1793,8 +1791,6 @@ iwl_mld_send_proto_offload(struct iwl_mld *mld,
};
u32 enabled = 0;
- cmd = kzalloc(hcmd.len[0], GFP_KERNEL);
-
#if IS_ENABLED(CONFIG_IPV6)
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
struct iwl_mld_wowlan_data *wowlan_data = &mld_vif->wowlan_data;
---
base-commit: c9cfc122f03711a5124b4aafab3211cf4d35a2ac
change-id: 20251105-aheev-uninitialized-free-attr-wireless-bde764fbe81c
Best regards,
--
Ally Heev <allyheev@...il.com>
Powered by blists - more mailing lists