Skip to content

Commit 56989f6

Browse files
jmberg-inteldavem330
authored andcommitted
genetlink: mark families as __ro_after_init
Now genl_register_family() is the only thing (other than the users themselves, perhaps, but I didn't find any doing that) writing to the family struct. In all families that I found, genl_register_family() is only called from __init functions (some indirectly, in which case I've add __init annotations to clarifly things), so all can actually be marked __ro_after_init. This protects the data structure from accidental corruption. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2ae0f17 commit 56989f6

File tree

35 files changed

+51
-51
lines changed

35 files changed

+51
-51
lines changed

drivers/acpi/event.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static const struct genl_multicast_group acpi_event_mcgrps[] = {
8282
{ .name = ACPI_GENL_MCAST_GROUP_NAME, },
8383
};
8484

85-
static struct genl_family acpi_event_genl_family = {
85+
static struct genl_family acpi_event_genl_family __ro_after_init = {
8686
.module = THIS_MODULE,
8787
.name = ACPI_GENL_FAMILY_NAME,
8888
.version = ACPI_GENL_VERSION,
@@ -144,7 +144,7 @@ int acpi_bus_generate_netlink_event(const char *device_class,
144144

145145
EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
146146

147-
static int acpi_event_genetlink_init(void)
147+
static int __init acpi_event_genetlink_init(void)
148148
{
149149
return genl_register_family(&acpi_event_genl_family);
150150
}

drivers/net/gtp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ static const struct genl_ops gtp_genl_ops[] = {
12901290
},
12911291
};
12921292

1293-
static struct genl_family gtp_genl_family = {
1293+
static struct genl_family gtp_genl_family __ro_after_init = {
12941294
.name = "gtp",
12951295
.version = 0,
12961296
.hdrsize = 0,

drivers/net/macsec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,7 @@ static const struct genl_ops macsec_genl_ops[] = {
26482648
},
26492649
};
26502650

2651-
static struct genl_family macsec_fam = {
2651+
static struct genl_family macsec_fam __ro_after_init = {
26522652
.name = MACSEC_GENL_NAME,
26532653
.hdrsize = 0,
26542654
.version = MACSEC_GENL_VERSION,

drivers/net/team/team.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,7 +2740,7 @@ static const struct genl_multicast_group team_nl_mcgrps[] = {
27402740
{ .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, },
27412741
};
27422742

2743-
static struct genl_family team_nl_family = {
2743+
static struct genl_family team_nl_family __ro_after_init = {
27442744
.name = TEAM_GENL_NAME,
27452745
.version = TEAM_GENL_VERSION,
27462746
.maxattr = TEAM_ATTR_MAX,
@@ -2773,7 +2773,7 @@ static int team_nl_send_event_port_get(struct team *team,
27732773
port);
27742774
}
27752775

2776-
static int team_nl_init(void)
2776+
static int __init team_nl_init(void)
27772777
{
27782778
return genl_register_family(&team_nl_family);
27792779
}

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,7 @@ static const struct genl_ops hwsim_ops[] = {
32283228
},
32293229
};
32303230

3231-
static struct genl_family hwsim_genl_family = {
3231+
static struct genl_family hwsim_genl_family __ro_after_init = {
32323232
.name = "MAC80211_HWSIM",
32333233
.version = 1,
32343234
.maxattr = HWSIM_ATTR_MAX,
@@ -3287,7 +3287,7 @@ static struct notifier_block hwsim_netlink_notifier = {
32873287
.notifier_call = mac80211_hwsim_netlink_notify,
32883288
};
32893289

3290-
static int hwsim_init_netlink(void)
3290+
static int __init hwsim_init_netlink(void)
32913291
{
32923292
int rc;
32933293

drivers/scsi/pmcraid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ static struct genl_multicast_group pmcraid_mcgrps[] = {
13681368
{ .name = "events", /* not really used - see ID discussion below */ },
13691369
};
13701370

1371-
static struct genl_family pmcraid_event_family = {
1371+
static struct genl_family pmcraid_event_family __ro_after_init = {
13721372
.module = THIS_MODULE,
13731373
.name = "pmcraid",
13741374
.version = 1,
@@ -1384,7 +1384,7 @@ static struct genl_family pmcraid_event_family = {
13841384
* 0 if the pmcraid_event_family is successfully registered
13851385
* with netlink generic, non-zero otherwise
13861386
*/
1387-
static int pmcraid_netlink_init(void)
1387+
static int __init pmcraid_netlink_init(void)
13881388
{
13891389
int result;
13901390

drivers/target/target_core_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static const struct genl_multicast_group tcmu_mcgrps[] = {
147147
};
148148

149149
/* Our generic netlink family */
150-
static struct genl_family tcmu_genl_family = {
150+
static struct genl_family tcmu_genl_family __ro_after_init = {
151151
.module = THIS_MODULE,
152152
.hdrsize = 0,
153153
.name = "TCM-USER",

drivers/thermal/thermal_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,7 @@ static const struct genl_multicast_group thermal_event_mcgrps[] = {
21632163
{ .name = THERMAL_GENL_MCAST_GROUP_NAME, },
21642164
};
21652165

2166-
static struct genl_family thermal_event_genl_family = {
2166+
static struct genl_family thermal_event_genl_family __ro_after_init = {
21672167
.module = THIS_MODULE,
21682168
.name = THERMAL_GENL_FAMILY_NAME,
21692169
.version = THERMAL_GENL_VERSION,
@@ -2235,7 +2235,7 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz,
22352235
}
22362236
EXPORT_SYMBOL_GPL(thermal_generate_netlink_event);
22372237

2238-
static int genetlink_init(void)
2238+
static int __init genetlink_init(void)
22392239
{
22402240
return genl_register_family(&thermal_event_genl_family);
22412241
}

fs/dlm/netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static struct genl_ops dlm_nl_ops[] = {
7272
},
7373
};
7474

75-
static struct genl_family family = {
75+
static struct genl_family family __ro_after_init = {
7676
.name = DLM_GENL_NAME,
7777
.version = DLM_GENL_VERSION,
7878
.ops = dlm_nl_ops,

fs/quota/netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static const struct genl_multicast_group quota_mcgrps[] = {
1212
};
1313

1414
/* Netlink family structure for quota */
15-
static struct genl_family quota_genl_family = {
15+
static struct genl_family quota_genl_family __ro_after_init = {
1616
.module = THIS_MODULE,
1717
.hdrsize = 0,
1818
.name = "VFS_DQUOT",

0 commit comments

Comments
 (0)