Skip to content

Commit d7be102

Browse files
committed
cfg80211: initialize regulatory keys/database later
When cfg80211 is built as a module, everything is fine, and we can keep the code as is; in fact, we have to, because there can only be a single module_init(). When cfg80211 is built-in, however, it needs to initialize before drivers (device_initcall/module_init), and thus used to be at subsys_initcall(). I'd moved it to fs_initcall() earlier, where it can remain. However, this is still too early because at that point the key infrastructure hasn't been initialized yet, so X.509 certificates can't be parsed yet. To work around this problem, load the regdb keys only later in a late_initcall(), at which point the necessary infrastructure has been initialized. Fixes: 90a53e4 ("cfg80211: implement regdb signature checking") Reported-by: Xiaolong Ye <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 7cca2ac commit d7be102

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

net/wireless/reg.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3644,27 +3644,14 @@ void regulatory_propagate_dfs_state(struct wiphy *wiphy,
36443644
}
36453645
}
36463646

3647-
int __init regulatory_init(void)
3647+
static int __init regulatory_init_db(void)
36483648
{
3649-
int err = 0;
3649+
int err;
36503650

36513651
err = load_builtin_regdb_keys();
36523652
if (err)
36533653
return err;
36543654

3655-
reg_pdev = platform_device_register_simple("regulatory", 0, NULL, 0);
3656-
if (IS_ERR(reg_pdev))
3657-
return PTR_ERR(reg_pdev);
3658-
3659-
spin_lock_init(&reg_requests_lock);
3660-
spin_lock_init(&reg_pending_beacons_lock);
3661-
spin_lock_init(&reg_indoor_lock);
3662-
3663-
rcu_assign_pointer(cfg80211_regdomain, cfg80211_world_regdom);
3664-
3665-
user_alpha2[0] = '9';
3666-
user_alpha2[1] = '7';
3667-
36683655
/* We always try to get an update for the static regdomain */
36693656
err = regulatory_hint_core(cfg80211_world_regdom->alpha2);
36703657
if (err) {
@@ -3692,6 +3679,31 @@ int __init regulatory_init(void)
36923679

36933680
return 0;
36943681
}
3682+
#ifndef MODULE
3683+
late_initcall(regulatory_init_db);
3684+
#endif
3685+
3686+
int __init regulatory_init(void)
3687+
{
3688+
reg_pdev = platform_device_register_simple("regulatory", 0, NULL, 0);
3689+
if (IS_ERR(reg_pdev))
3690+
return PTR_ERR(reg_pdev);
3691+
3692+
spin_lock_init(&reg_requests_lock);
3693+
spin_lock_init(&reg_pending_beacons_lock);
3694+
spin_lock_init(&reg_indoor_lock);
3695+
3696+
rcu_assign_pointer(cfg80211_regdomain, cfg80211_world_regdom);
3697+
3698+
user_alpha2[0] = '9';
3699+
user_alpha2[1] = '7';
3700+
3701+
#ifdef MODULE
3702+
return regulatory_init_db();
3703+
#else
3704+
return 0;
3705+
#endif
3706+
}
36953707

36963708
void regulatory_exit(void)
36973709
{

0 commit comments

Comments
 (0)