Skip to contentSkip to conversation

iwlegacy: fix bugs in change_interface

PATCH Superseded Johannes Berg 2 participants 5 messages Mar 29, 2011 Networking drivers (wireless)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 iwlegacy: fix bugs in change_interface

From: Johannes Berg <[email protected]>

If change_interface gets invoked during a firmware restart, it may crash; prevent that from happening by checking if ctx->vif is assigned.

Additionally, in my initial commit I forgot to set the vif->p2p variable correctly, so fix that too, even if it doesn't matter since P2P isn't supported.

---
 drivers/net/wireless/iwlegacy/iwl-core.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/iwlegacy/iwl-core.c +10 -0
@@ -1805,6 +1805,15 @@ iwl_legacy_mac_change_interface(struct i
 
 	mutex_lock(&priv->mutex);
 
+	if (!ctx->vif) {
+		/*
+		 * Huh? But wait ... this can maybe happen when
+		 * we're in the middle of a firmware restart!
+		 */
+		err = -EBUSY;
+		goto out;
+	}
+
 	interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes;
 
 	if (!(interface_modes & BIT(newtype))) {
@@ -1832,6 +1841,7 @@ iwl_legacy_mac_change_interface(struct i
 	/* success */
 	iwl_legacy_teardown_interface(priv, vif, true);
 	vif->type = newtype;
+	vif->p2p = newp2p;
 	err = iwl_legacy_setup_interface(priv, ctx);
 	WARN_ON(err);
 	/*
#1 lore raw
Quoted 9 lines · Johannes Berg

From: Johannes Berg <[email protected]>

If change_interface gets invoked during a firmware restart, it may crash; prevent that from happening by checking if ctx->vif is assigned.

Additionally, in my initial commit I forgot to set the vif->p2p variable correctly, so fix that too, even if it doesn't matter since P2P isn't supported.

ACK

Does we also need iwl_{legacy,}is_ready_rf check?

Stanislaw

author maintainer
#2 lore raw
Quoted 7 lines · Stanislaw Gruszka
Quoted 6 lines · Johannes Berg

From: Johannes Berg <[email protected]>

If change_interface gets invoked during a firmware restart, it may crash; prevent that from happening by checking if ctx->vif is assigned.

Quoted 7 lines
Quoted 3 lines

Additionally, in my initial commit I forgot to set the vif->p2p variable correctly, so fix that too, even if it doesn't matter since P2P isn't supported.

ACK

Does we also need iwl_{legacy,}is_ready_rf check?

Good question, I guess it wouldn't hurt.

FWIW, I'm submitting the iwlagn version (which looks just the same) to our own testing first.

johannes

author maintainer
#3 lore raw

PATCH v2 1/1 iwlegacy: fix bugs in change_interface

From: Johannes Berg <[email protected]>

If change_interface gets invoked during a firmware restart, it may crash; prevent that from happening by checking if ctx->vif is assigned.

Additionally, in my initial commit I forgot to set the vif->p2p variable correctly, so fix that too.

---
 drivers/net/wireless/iwlegacy/iwl-core.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/iwlegacy/iwl-core.c +10 -0
@@ -1805,6 +1805,15 @@ iwl_legacy_mac_change_interface(struct i
 
 	mutex_lock(&priv->mutex);
 
+	if (!ctx->vif || !iwl_legacy_is_ready_rf(priv)) {
+		/*
+		 * Huh? But wait ... this can maybe happen when
+		 * we're in the middle of a firmware restart!
+		 */
+		err = -EBUSY;
+		goto out;
+	}
+
 	interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes;
 
 	if (!(interface_modes & BIT(newtype))) {
@@ -1832,6 +1841,7 @@ iwl_legacy_mac_change_interface(struct i
 	/* success */
 	iwl_legacy_teardown_interface(priv, vif, true);
 	vif->type = newtype;
+	vif->p2p = newp2p;
 	err = iwl_legacy_setup_interface(priv, ctx);
 	WARN_ON(err);
 	/*