Skip to content

Commit a571bc2

Browse files
tititiou36Kalle Valo
authored andcommitted
iwlwifi: Fix memory leaks in error handling path
Should an error occur (invalid TLV len or memory allocation failure), the memory already allocated in 'reduce_power_data' should be freed before returning, otherwise it is leaking. Fixes: 9dad325 ("iwlwifi: support loading the reduced power table from UEFI") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/1504cd7d842d13ddb8244e18004523128d5c9523.1636615284.git.christophe.jaillet@wanadoo.fr
1 parent f5cecf1 commit a571bc2

File tree

1 file changed

+6
-0
lines changed
  • drivers/net/wireless/intel/iwlwifi/fw

1 file changed

+6
-0
lines changed

drivers/net/wireless/intel/iwlwifi/fw/uefi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static void *iwl_uefi_reduce_power_section(struct iwl_trans *trans,
8686
if (len < tlv_len) {
8787
IWL_ERR(trans, "invalid TLV len: %zd/%u\n",
8888
len, tlv_len);
89+
kfree(reduce_power_data);
8990
reduce_power_data = ERR_PTR(-EINVAL);
9091
goto out;
9192
}
@@ -105,6 +106,7 @@ static void *iwl_uefi_reduce_power_section(struct iwl_trans *trans,
105106
IWL_DEBUG_FW(trans,
106107
"Couldn't allocate (more) reduce_power_data\n");
107108

109+
kfree(reduce_power_data);
108110
reduce_power_data = ERR_PTR(-ENOMEM);
109111
goto out;
110112
}
@@ -134,6 +136,10 @@ static void *iwl_uefi_reduce_power_section(struct iwl_trans *trans,
134136
done:
135137
if (!size) {
136138
IWL_DEBUG_FW(trans, "Empty REDUCE_POWER, skipping.\n");
139+
/* Better safe than sorry, but 'reduce_power_data' should
140+
* always be NULL if !size.
141+
*/
142+
kfree(reduce_power_data);
137143
reduce_power_data = ERR_PTR(-ENOENT);
138144
goto out;
139145
}

0 commit comments

Comments
 (0)