Skip to content

Commit 3b1c256

Browse files
Aloka Dixitjmberg-intel
authored andcommitted
wifi: mac80211: fixes in FILS discovery updates
FILS discovery configuration gets updated only if the maximum interval is set to a non-zero value, hence there is no way to reset this value to 0 once set. Replace the check for interval with a new flag which is set only if the configuration should be updated. Add similar changes for the unsolicited broadcast probe response handling. Signed-off-by: Aloka Dixit <[email protected]> Reviewed-by: Jeff Johnson <[email protected]> Link: https://lore.kernel.org/r/[email protected] [move NULL'ing to else branch to not have intermediate NULL visible] Signed-off-by: Johannes Berg <[email protected]>
1 parent 0cfaec2 commit 3b1c256

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

net/mac80211/cfg.c

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -952,25 +952,29 @@ static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
952952
struct fils_discovery_data *new, *old = NULL;
953953
struct ieee80211_fils_discovery *fd;
954954

955-
if (!params->tmpl || !params->tmpl_len)
956-
return -EINVAL;
955+
if (!params->update)
956+
return 0;
957957

958958
fd = &link_conf->fils_discovery;
959959
fd->min_interval = params->min_interval;
960960
fd->max_interval = params->max_interval;
961961

962962
old = sdata_dereference(link->u.ap.fils_discovery, sdata);
963-
new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
964-
if (!new)
965-
return -ENOMEM;
966-
new->len = params->tmpl_len;
967-
memcpy(new->data, params->tmpl, params->tmpl_len);
968-
rcu_assign_pointer(link->u.ap.fils_discovery, new);
969-
970963
if (old)
971964
kfree_rcu(old, rcu_head);
972965

973-
return 0;
966+
if (params->tmpl && params->tmpl_len) {
967+
new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
968+
if (!new)
969+
return -ENOMEM;
970+
new->len = params->tmpl_len;
971+
memcpy(new->data, params->tmpl, params->tmpl_len);
972+
rcu_assign_pointer(link->u.ap.fils_discovery, new);
973+
} else {
974+
RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
975+
}
976+
977+
return BSS_CHANGED_FILS_DISCOVERY;
974978
}
975979

976980
static int
@@ -981,23 +985,27 @@ ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
981985
{
982986
struct unsol_bcast_probe_resp_data *new, *old = NULL;
983987

984-
if (!params->tmpl || !params->tmpl_len)
985-
return -EINVAL;
988+
if (!params->update)
989+
return 0;
986990

987-
old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
988-
new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
989-
if (!new)
990-
return -ENOMEM;
991-
new->len = params->tmpl_len;
992-
memcpy(new->data, params->tmpl, params->tmpl_len);
993-
rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
991+
link_conf->unsol_bcast_probe_resp_interval = params->interval;
994992

993+
old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
995994
if (old)
996995
kfree_rcu(old, rcu_head);
997996

998-
link_conf->unsol_bcast_probe_resp_interval = params->interval;
997+
if (params->tmpl && params->tmpl_len) {
998+
new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
999+
if (!new)
1000+
return -ENOMEM;
1001+
new->len = params->tmpl_len;
1002+
memcpy(new->data, params->tmpl, params->tmpl_len);
1003+
rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
1004+
} else {
1005+
RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1006+
}
9991007

1000-
return 0;
1008+
return BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
10011009
}
10021010

10031011
static int ieee80211_set_ftm_responder_params(
@@ -1428,23 +1436,18 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
14281436
if (err < 0)
14291437
goto error;
14301438

1431-
if (params->fils_discovery.max_interval) {
1432-
err = ieee80211_set_fils_discovery(sdata,
1433-
&params->fils_discovery,
1434-
link, link_conf);
1435-
if (err < 0)
1436-
goto error;
1437-
changed |= BSS_CHANGED_FILS_DISCOVERY;
1438-
}
1439+
err = ieee80211_set_fils_discovery(sdata, &params->fils_discovery,
1440+
link, link_conf);
1441+
if (err < 0)
1442+
goto error;
1443+
changed |= err;
14391444

1440-
if (params->unsol_bcast_probe_resp.interval) {
1441-
err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1442-
&params->unsol_bcast_probe_resp,
1443-
link, link_conf);
1444-
if (err < 0)
1445-
goto error;
1446-
changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1447-
}
1445+
err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1446+
&params->unsol_bcast_probe_resp,
1447+
link, link_conf);
1448+
if (err < 0)
1449+
goto error;
1450+
changed |= err;
14481451

14491452
err = drv_start_ap(sdata->local, sdata, link_conf);
14501453
if (err) {

0 commit comments

Comments
 (0)