Skip to content

Commit

Permalink
iwlegacy: make il3945_mac_ops __ro_after_init
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
  • Loading branch information
jmberg-intel authored and Kalle Valo committed Dec 30, 2016
1 parent d7864cf commit ae3cf47
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/net/wireless/intel/iwlegacy/3945-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -3469,7 +3469,7 @@ static struct attribute_group il3945_attribute_group = {
.attrs = il3945_sysfs_entries,
};

static struct ieee80211_ops il3945_mac_ops __read_mostly = {
static struct ieee80211_ops il3945_mac_ops __ro_after_init = {
.tx = il3945_mac_tx,
.start = il3945_mac_start,
.stop = il3945_mac_stop,
Expand Down Expand Up @@ -3627,15 +3627,6 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

il->cmd_queue = IL39_CMD_QUEUE_NUM;

/*
* Disabling hardware scan means that mac80211 will perform scans
* "the hard way", rather than using device's scan.
*/
if (il3945_mod_params.disable_hw_scan) {
D_INFO("Disabling hw_scan\n");
il3945_mac_ops.hw_scan = NULL;
}

D_INFO("*** LOAD DRIVER ***\n");
il->cfg = cfg;
il->ops = &il3945_ops;
Expand Down Expand Up @@ -3913,6 +3904,15 @@ il3945_init(void)
pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n");
pr_info(DRV_COPYRIGHT "\n");

/*
* Disabling hardware scan means that mac80211 will perform scans
* "the hard way", rather than using device's scan.
*/
if (il3945_mod_params.disable_hw_scan) {
pr_info("hw_scan is disabled\n");
il3945_mac_ops.hw_scan = NULL;
}

ret = il3945_rate_control_register();
if (ret) {
pr_err("Unable to register rate control algorithm: %d\n", ret);
Expand Down

0 comments on commit ae3cf47

Please sign in to comment.