mac80211: check add_chanctx callback before use in ieee80211_reconfig
PATCH 1/1 mac80211: check add_chanctx callback before use in ieee80211_reconfig
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().
--- net/mac80211/util.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/mac80211/util.c +6 -4
@@ -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;
Signature · 1 line
1.7.10.4
hi Arend,
Quoted 10 lines · Arend van Spriel
During testing our mac80211 driver a fatal error occurred which was signalled to mac80211. Upon performing the reconfiguration of the device a
WARN_ONwas triggered. This warning checked the return value ofdrv_add_chanctx(). However, this returns-EOPNOTSUPPwhen the driver does not provide the callback. As the callback is optional better check it is defined before callingdrv_add_chanctx().Signed-off-by Arend van Spriel <[email protected]>---
net/mac80211/util.c int ieee80211_reconfig(struct ieee80211_local *local) · line 1425
Quoted 6 lines
net/mac80211/util.c +6
-0+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.
Johannes Berg
maintainerQuoted 13 lines · Eliad Peller
hi Arend,
Quoted 9 lines · Arend van Spriel
During testing our mac80211 driver a fatal error occurred which was signalled to mac80211. Upon performing the reconfiguration of the device a
WARN_ONwas triggered. This warning checked the return value ofdrv_add_chanctx(). However, this returns-EOPNOTSUPPwhen the driver does not provide the callback. As the callback is optional better check it is defined before callingdrv_add_chanctx().Signed-off-by Arend van Spriel <[email protected]>---
Quoted 8 lines
net/mac80211/util.c int ieee80211_reconfig(struct ieee80211_local *local) · line 1425
Quoted 6 lines
net/mac80211/util.c +6
-0+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_chanctxis a bit cleaner.
Makes sense, I'll apply with this change.
johannes