Skip to content

Commit

Permalink
wifi: iwlwifi: yoyo: Fix possible division by zero
Browse files Browse the repository at this point in the history
[ Upstream commit ba30415 ]

Don't allow buffer allocation TLV with zero req_size since it
leads later to division by zero in iwl_dbg_tlv_alloc_fragments().
Also, NPK/SRAM locations are allowed to have zero buffer req_size,
don't discard them.

Fixes: a9248de ("iwlwifi: dbg_ini: add TLV allocation new API support")
Signed-off-by: Daniel Gabay <daniel.gabay@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230413213309.5d6688ed74d8.I5c2f3a882b50698b708d54f4524dc5bdf11e3d32@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
gabayd authored and gregkh committed May 11, 2023
1 parent db407b0 commit 4ad494f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ static int iwl_dbg_tlv_alloc_buf_alloc(struct iwl_trans *trans,
alloc_id != IWL_FW_INI_ALLOCATION_ID_DBGC1)
goto err;

if (buf_location == IWL_FW_INI_LOCATION_DRAM_PATH &&
alloc->req_size == 0) {
IWL_ERR(trans, "WRT: Invalid DRAM buffer allocation requested size (0)\n");
return -EINVAL;
}

trans->dbg.fw_mon_cfg[alloc_id] = *alloc;

return 0;
Expand Down

0 comments on commit 4ad494f

Please sign in to comment.