All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers:wireless: Fix a dereference before null check issue
@ 2024-11-21 17:02 Paolo Perego
  2024-11-21 17:28 ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Perego @ 2024-11-21 17:02 UTC (permalink / raw)
  To: linux-wireless, linux-kernel
  Cc: Miri Korenblit, Kalle Valo, Johannes Berg, Shaul Triebitz,
	Emmanuel Grumbach, Yedidya Benshimol, Benjamin Berg, Paolo Perego

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@suse.de>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-22  7:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 17:02 [PATCH] drivers:wireless: Fix a dereference before null check issue Paolo Perego
2024-11-21 17:28 ` Johannes Berg
2024-11-21 17:35   ` Paolo Perego
2024-11-21 17:40     ` Johannes Berg
2024-11-22  7:50     ` wireless: " Markus Elfring
2024-11-22  7:25   ` Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.