diff mbox series

[net,v2] ethtool: mark netlink family as __ro_after_init

Message ID 20200929005841.3640817-1-kuba@kernel.org
State Superseded
Headers show
Series [net,v2] ethtool: mark netlink family as __ro_after_init | expand

Commit Message

Jakub Kicinski Sept. 29, 2020, 12:58 a.m. UTC
Like all genl families ethtool_genl_family needs to not
be a straight up constant, because it's modified/initialized
by genl_register_family(). After init, however, it's only
passed to genlmsg_put() & co. therefore we can mark it
as __ro_after_init.

Since genl_family structure contains function pointers
mark this as a fix.

Fixes: 2b4a8990b7df ("ethtool: introduce ethtool netlink interface")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ethtool/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Sept. 29, 2020, 1:53 a.m. UTC | #1
From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 28 Sep 2020 17:58:41 -0700

> Like all genl families ethtool_genl_family needs to not
> be a straight up constant, because it's modified/initialized
> by genl_register_family(). After init, however, it's only
> passed to genlmsg_put() & co. therefore we can mark it
> as __ro_after_init.
> 
> Since genl_family structure contains function pointers
> mark this as a fix.
> 
> Fixes: 2b4a8990b7df ("ethtool: introduce ethtool netlink interface")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Applied.
diff mbox series

Patch

diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 5c2072765be7..0c3f54baec4e 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -866,7 +866,7 @@  static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
 	[ETHNL_MCGRP_MONITOR] = { .name = ETHTOOL_MCGRP_MONITOR_NAME },
 };
 
-static struct genl_family ethtool_genl_family = {
+static struct genl_family ethtool_genl_family __ro_after_init = {
 	.name		= ETHTOOL_GENL_NAME,
 	.version	= ETHTOOL_GENL_VERSION,
 	.netnsok	= true,