diff mbox

mac80211: check add_chanctx callback before use in ieee80211_reconfig

Message ID 1353322865-7500-1-git-send-email-arend@broadcom.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Arend van Spriel Nov. 19, 2012, 11:01 a.m. UTC
During testing our mac80211 driver a fatal error occurred which was
signalled to mac80211. Upon performing the reconfiguration of the
device a WARN_ON was triggered. This warning checked the return value
of drv_add_chanctx(). However, this returns -EOPNOTSUPP when the
driver does not provide the callback. As the callback is optional
better check it is defined before calling drv_add_chanctx().

Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 net/mac80211/util.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Eliad Peller Nov. 19, 2012, 1:36 p.m. UTC | #1
hi Arend,

On Mon, Nov 19, 2012 at 1:01 PM, Arend van Spriel <arend@broadcom.com> wrote:
> During testing our mac80211 driver a fatal error occurred which was
> signalled to mac80211. Upon performing the reconfiguration of the
> device a WARN_ON was triggered. This warning checked the return value
> of drv_add_chanctx(). However, this returns -EOPNOTSUPP when the
> driver does not provide the callback. As the callback is optional
> better check it is defined before calling drv_add_chanctx().
>
> Signed-off-by: Arend van Spriel <arend@broadcom.com>
> ---

> +       if (local->ops->add_chanctx) {
> +               mutex_lock(&local->chanctx_mtx);
> +               list_for_each_entry(ctx, &local->chanctx_list, list)
> +                       WARN_ON(drv_add_chanctx(local, ctx));
> +               mutex_unlock(&local->chanctx_mtx);
> +       }

i think checking local->use_chanctx is a bit cleaner.

Eliad.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Nov. 19, 2012, 1:47 p.m. UTC | #2
On Mon, 2012-11-19 at 15:36 +0200, Eliad Peller wrote:
> hi Arend,
> 
> On Mon, Nov 19, 2012 at 1:01 PM, Arend van Spriel <arend@broadcom.com> wrote:
> > During testing our mac80211 driver a fatal error occurred which was
> > signalled to mac80211. Upon performing the reconfiguration of the
> > device a WARN_ON was triggered. This warning checked the return value
> > of drv_add_chanctx(). However, this returns -EOPNOTSUPP when the
> > driver does not provide the callback. As the callback is optional
> > better check it is defined before calling drv_add_chanctx().
> >
> > Signed-off-by: Arend van Spriel <arend@broadcom.com>
> > ---
> 
> > +       if (local->ops->add_chanctx) {
> > +               mutex_lock(&local->chanctx_mtx);
> > +               list_for_each_entry(ctx, &local->chanctx_list, list)
> > +                       WARN_ON(drv_add_chanctx(local, ctx));
> > +               mutex_unlock(&local->chanctx_mtx);
> > +       }
> 
> i think checking local->use_chanctx is a bit cleaner.

Makes sense, I'll apply with this change.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 5bad758..9c3b3ba 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1417,10 +1417,12 @@  int ieee80211_reconfig(struct ieee80211_local *local)
 	}
 
 	/* add channel contexts */
-	mutex_lock(&local->chanctx_mtx);
-	list_for_each_entry(ctx, &local->chanctx_list, list)
-		WARN_ON(drv_add_chanctx(local, ctx));
-	mutex_unlock(&local->chanctx_mtx);
+	if (local->ops->add_chanctx) {
+		mutex_lock(&local->chanctx_mtx);
+		list_for_each_entry(ctx, &local->chanctx_list, list)
+			WARN_ON(drv_add_chanctx(local, ctx));
+		mutex_unlock(&local->chanctx_mtx);
+	}
 
 	list_for_each_entry(sdata, &local->interfaces, list) {
 		struct ieee80211_chanctx_conf *ctx_conf;