Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iwlegacy: make il3945_mac_ops __ro_after_init

There's no need for this to be only __read_mostly, since
it's only written in a single way depending on the module
parameter, so that can be moved into the module's __init
function, and the ops can be __ro_after_init.

This is a little bit safer since it means the ops can't
be overwritten (accidentally or otherwise), which would
otherwise cause an arbitrary function or bad pointer to
be called.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Johannes Berg and committed by
Kalle Valo
ae3cf476 d7864cf2

+10 -10
+10 -10
drivers/net/wireless/intel/iwlegacy/3945-mac.c
··· 3469 3469 .attrs = il3945_sysfs_entries, 3470 3470 }; 3471 3471 3472 - static struct ieee80211_ops il3945_mac_ops __read_mostly = { 3472 + static struct ieee80211_ops il3945_mac_ops __ro_after_init = { 3473 3473 .tx = il3945_mac_tx, 3474 3474 .start = il3945_mac_start, 3475 3475 .stop = il3945_mac_stop, ··· 3626 3626 SET_IEEE80211_DEV(hw, &pdev->dev); 3627 3627 3628 3628 il->cmd_queue = IL39_CMD_QUEUE_NUM; 3629 - 3630 - /* 3631 - * Disabling hardware scan means that mac80211 will perform scans 3632 - * "the hard way", rather than using device's scan. 3633 - */ 3634 - if (il3945_mod_params.disable_hw_scan) { 3635 - D_INFO("Disabling hw_scan\n"); 3636 - il3945_mac_ops.hw_scan = NULL; 3637 - } 3638 3629 3639 3630 D_INFO("*** LOAD DRIVER ***\n"); 3640 3631 il->cfg = cfg; ··· 3903 3912 int ret; 3904 3913 pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); 3905 3914 pr_info(DRV_COPYRIGHT "\n"); 3915 + 3916 + /* 3917 + * Disabling hardware scan means that mac80211 will perform scans 3918 + * "the hard way", rather than using device's scan. 3919 + */ 3920 + if (il3945_mod_params.disable_hw_scan) { 3921 + pr_info("hw_scan is disabled\n"); 3922 + il3945_mac_ops.hw_scan = NULL; 3923 + } 3906 3924 3907 3925 ret = il3945_rate_control_register(); 3908 3926 if (ret) {