aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-11-19 09:19:39 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-19 16:39:06 -0500
commit2a94fe48f32ccf7321450a2cc07f2b724a444e5b (patch)
treee5a066d8f83d8822d448421019a4503f361295f9 /drivers/acpi
parent68eb55031da7c967d954e5f9415cd05f4abdb692 (diff)
genetlink: make multicast groups const, prevent abuse
Register generic netlink multicast groups as an array with the family and give them contiguous group IDs. Then instead of passing the global group ID to the various functions that send messages, pass the ID relative to the family - for most families that's just 0 because the only have one group. This avoids the list_head and ID in each group, adding a new field for the mcast group ID offset to the family. At the same time, this allows us to prevent abusing groups again like the quota and dropmon code did, since we can now check that a family only uses a group it owns. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/event.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 68a8755202ec..aeb5aa6ce068 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -78,15 +78,17 @@ enum {
78#define ACPI_GENL_VERSION 0x01 78#define ACPI_GENL_VERSION 0x01
79#define ACPI_GENL_MCAST_GROUP_NAME "acpi_mc_group" 79#define ACPI_GENL_MCAST_GROUP_NAME "acpi_mc_group"
80 80
81static const struct genl_multicast_group acpi_event_mcgrps[] = {
82 { .name = ACPI_GENL_MCAST_GROUP_NAME, },
83};
84
81static struct genl_family acpi_event_genl_family = { 85static struct genl_family acpi_event_genl_family = {
82 .id = GENL_ID_GENERATE, 86 .id = GENL_ID_GENERATE,
83 .name = ACPI_GENL_FAMILY_NAME, 87 .name = ACPI_GENL_FAMILY_NAME,
84 .version = ACPI_GENL_VERSION, 88 .version = ACPI_GENL_VERSION,
85 .maxattr = ACPI_GENL_ATTR_MAX, 89 .maxattr = ACPI_GENL_ATTR_MAX,
86}; 90 .mcgrps = acpi_event_mcgrps,
87 91 .n_mcgrps = ARRAY_SIZE(acpi_event_mcgrps),
88static struct genl_multicast_group acpi_event_mcgrp = {
89 .name = ACPI_GENL_MCAST_GROUP_NAME,
90}; 92};
91 93
92int acpi_bus_generate_netlink_event(const char *device_class, 94int acpi_bus_generate_netlink_event(const char *device_class,
@@ -146,8 +148,7 @@ int acpi_bus_generate_netlink_event(const char *device_class,
146 return result; 148 return result;
147 } 149 }
148 150
149 genlmsg_multicast(&acpi_event_genl_family, 151 genlmsg_multicast(&acpi_event_genl_family, skb, 0, 0, GFP_ATOMIC);
150 skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC);
151 return 0; 152 return 0;
152} 153}
153 154
@@ -155,18 +156,7 @@ EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
155 156
156static int acpi_event_genetlink_init(void) 157static int acpi_event_genetlink_init(void)
157{ 158{
158 int result; 159 return genl_register_family(&acpi_event_genl_family);
159
160 result = genl_register_family(&acpi_event_genl_family);
161 if (result)
162 return result;
163
164 result = genl_register_mc_group(&acpi_event_genl_family,
165 &acpi_event_mcgrp);
166 if (result)
167 genl_unregister_family(&acpi_event_genl_family);
168
169 return result;
170} 160}
171 161
172#else 162#else