Skip to content

Commit 644e9ea

Browse files
dmantipovSasha Levin
authored andcommitted
wifi: iwlwifi: check for kmemdup() return value in iwl_parse_tlv_firmware()
[ Upstream commit 3c8aaaa ] In 'iwl_parse_tlv_firmware()', check for 'kmemdup()' return value when handling IWL_UCODE_TLV_CURRENT_PC and set the number of parsed entries only if an allocation was successful (just like it does with handling IWL_UCODE_TLV_CMD_VERSIONS above). Compile tested only. Signed-off-by: Dmitry Antipov <[email protected]> Acked-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 86d6c44 commit 644e9ea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/wireless/intel/iwlwifi/iwl-drv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,10 +1304,12 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
13041304
case IWL_UCODE_TLV_CURRENT_PC:
13051305
if (tlv_len < sizeof(struct iwl_pc_data))
13061306
goto invalid_tlv_len;
1307-
drv->trans->dbg.num_pc =
1308-
tlv_len / sizeof(struct iwl_pc_data);
13091307
drv->trans->dbg.pc_data =
13101308
kmemdup(tlv_data, tlv_len, GFP_KERNEL);
1309+
if (!drv->trans->dbg.pc_data)
1310+
return -ENOMEM;
1311+
drv->trans->dbg.num_pc =
1312+
tlv_len / sizeof(struct iwl_pc_data);
13111313
break;
13121314
default:
13131315
IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);

0 commit comments

Comments
 (0)