Skip to contentSkip to conversation

iwl3945: fix possible il->txq NULL pointer dereference in delayed works

PATCH New Stanislaw Gruszka 1 participant 1 message Mar 8, 2012 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iwl3945: fix possible il->txq NULL pointer dereference in delayed works

On il3945_down procedure we free tx queue data and nullify il->txq pointer. After that we drop mutex and then cancel delayed works. There is possibility, that after drooping mutex and before the cancel, some delayed work will start and crash while trying to send commands to the device. For example, here is reported crash in il3945_bg_reg_txpower_periodic():
https://bugzilla.kernel.org/show_bug.cgi?id=42766#c10

Patch fix problem by adding il->txq check on works that send commands, hence utilize tx queue.

---
 drivers/net/wireless/iwlegacy/3945-mac.c |    2 +-
 drivers/net/wireless/iwlegacy/3945.c     |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/iwlegacy/3945-mac.c +1 -1
index 0ccc934..0c12093 100644
@@ -2466,7 +2466,7 @@ il3945_bg_alive_start(struct work_struct *data)
 	    container_of(data, struct il_priv, alive_start.work);
 
 	mutex_lock(&il->mutex);
-	if (test_bit(S_EXIT_PENDING, &il->status))
+	if (test_bit(S_EXIT_PENDING, &il->status) || il->txq == NULL)
 		goto out;
 
 	il3945_alive_start(il);
drivers/net/wireless/iwlegacy/3945.c +4 -3
index 456f32d..c5b1d19 100644
@@ -1855,11 +1855,12 @@ il3945_bg_reg_txpower_periodic(struct work_struct *work)
 	struct il_priv *il = container_of(work, struct il_priv,
 					  _3945.thermal_periodic.work);
 
-	if (test_bit(S_EXIT_PENDING, &il->status))
-		return;
-
 	mutex_lock(&il->mutex);
+	if (test_bit(S_EXIT_PENDING, &il->status) || il->txq == NULL)
+		goto out;
+
 	il3945_reg_txpower_periodic(il);
+out:
 	mutex_unlock(&il->mutex);
 }
 
Signature · 1 line
1.7.1