mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
wifi: iwlwifi: uefi: remove runtime check of constant values
There's no need to check an ARRAY_SIZE() at runtime, it's already determined at build time, so could be a BUILD_BUG_ON. However it's not that useful here since the array is defined using UEFI_MAX_DSM_FUNCS, check DSM_FUNC_NUM_FUNCS instead to ensure the array cannot be accessed out-of-band, i.e. ensure the range check there is always good enough. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20250828111032.cc3c17327ea2.I99c7175be1f72f29b154454fc24978daafad476f@changeid
This commit is contained in:
parent
5272d45914
commit
f53f2bd8fc
|
|
@ -727,6 +727,8 @@ int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
|
|||
struct uefi_cnv_var_general_cfg *data;
|
||||
int ret = -EINVAL;
|
||||
|
||||
BUILD_BUG_ON(ARRAY_SIZE(data->functions) < DSM_FUNC_NUM_FUNCS);
|
||||
|
||||
/* Not supported function index */
|
||||
if (func >= DSM_FUNC_NUM_FUNCS || func == 5)
|
||||
return -EOPNOTSUPP;
|
||||
|
|
@ -742,11 +744,6 @@ int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (ARRAY_SIZE(data->functions) != UEFI_MAX_DSM_FUNCS) {
|
||||
IWL_DEBUG_RADIO(fwrt, "Invalid size of DSM functions array\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
*value = data->functions[func];
|
||||
|
||||
IWL_DEBUG_RADIO(fwrt,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user