Skip to content

Commit 45010c0

Browse files
tititiou36Kalle Valo
authored andcommitted
iwlwifi: pnvm: Fix a memory leak in 'iwl_pnvm_get_from_fs()'
A firmware is requested but never released in this function. This leads to a memory leak in the normal execution path. Add the missing 'release_firmware()' call. Also introduce a temp variable (new_len) in order to keep the value of 'pnvm->size' after the firmware has been released. Fixes: cdda18f ("iwlwifi: pnvm: move file loading code to a separate function") Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Acked-by: Luca Coelho <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/1b5d80f54c1dbf85710fd285243932943b498fe7.1630614969.git.christophe.jaillet@wanadoo.fr
1 parent 851c8e7 commit 45010c0

File tree

1 file changed

+5
-1
lines changed
  • drivers/net/wireless/intel/iwlwifi/fw

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len)
231231
{
232232
const struct firmware *pnvm;
233233
char pnvm_name[MAX_PNVM_NAME];
234+
size_t new_len;
234235
int ret;
235236

236237
iwl_pnvm_get_fs_name(trans, pnvm_name, sizeof(pnvm_name));
@@ -242,11 +243,14 @@ static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len)
242243
return ret;
243244
}
244245

246+
new_len = pnvm->size;
245247
*data = kmemdup(pnvm->data, pnvm->size, GFP_KERNEL);
248+
release_firmware(pnvm);
249+
246250
if (!*data)
247251
return -ENOMEM;
248252

249-
*len = pnvm->size;
253+
*len = new_len;
250254

251255
return 0;
252256
}

0 commit comments

Comments
 (0)