This patch fixes a dereference before null check issue discovered by Coverity (CID 1601547) In iwl_mvm_parse_wowlan_info_notif() routine data is checked against NULL value at line 2501 but it has been dereferenced three lines before when calculating sizeof() in an assignment. Signed-off-by: Paolo Perego <pperego@xxxxxxx> --- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c index f85c01e04ebf..f733c16ffd8e 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c @@ -2495,8 +2495,7 @@ static void iwl_mvm_parse_wowlan_info_notif(struct iwl_mvm *mvm, struct iwl_wowlan_status_data *status, u32 len) { - u32 expected_len = sizeof(*data) + - data->num_mlo_link_keys * sizeof(status->mlo_keys[0]); + u32 expected_len = 0; if (!data) { IWL_ERR(mvm, "iwl_wowlan_info_notif data is NULL\n"); @@ -2504,6 +2503,8 @@ static void iwl_mvm_parse_wowlan_info_notif(struct iwl_mvm *mvm, return; } + expected_len = sizeof(*data) + data->num_mlo_link_keys * sizeof(status->mlo_keys[0]); + if (len < expected_len) { IWL_ERR(mvm, "Invalid WoWLAN info notification!\n"); status = NULL; -- 2.47.0