wifi: mac80211: simplify ieee80211_assign_link_chanctx()
authorJohannes Berg <johannes.berg@intel.com>
Thu, 18 Apr 2024 09:52:20 +0000 (11:52 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 19 Apr 2024 08:19:37 +0000 (10:19 +0200)
There's no need for a label/goto here, the only thing is
that drv_assign_vif_chanctx() must succeed to set 'conf'
and add the new context to the list, the remaining code
is (and must be) the same regardless.

Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://msgid.link/20240418115219.a94852030d33.I9d647178ab25636372ed79e5312c68a06e0bf60c@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/chan.c

index 6d0148dea1263e74f5eab745f7563dec365cbbe5..2c338014ded582400b04a8b3be15a718c8162861 100644 (file)
@@ -815,7 +815,7 @@ static int ieee80211_assign_link_chanctx(struct ieee80211_link_data *link,
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_chanctx_conf *conf;
        struct ieee80211_chanctx *curr_ctx = NULL;
-       int ret = 0;
+       int ret;
 
        if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_NAN))
                return -EOPNOTSUPP;
@@ -836,15 +836,16 @@ static int ieee80211_assign_link_chanctx(struct ieee80211_link_data *link,
                ieee80211_recalc_chanctx_min_def(local, new_ctx, link);
 
                ret = drv_assign_vif_chanctx(local, sdata, link->conf, new_ctx);
-               if (ret)
-                       goto out;
-
-               conf = &new_ctx->conf;
-               list_add(&link->assigned_chanctx_list,
-                        &new_ctx->assigned_links);
+               if (!ret) {
+                       /* succeeded, so commit it to the data structures */
+                       conf = &new_ctx->conf;
+                       list_add(&link->assigned_chanctx_list,
+                                &new_ctx->assigned_links);
+               }
+       } else {
+               ret = 0;
        }
 
-out:
        rcu_assign_pointer(link->conf->chanctx_conf, conf);
 
        sdata->vif.cfg.idle = !conf;