4.9 introduced __ro_after_init, but generic netlink family
registration was only changed to allow it in 4.10, otherwise
deregistration will crash due to writing to the RO memory.
Unfortunately, spatch doesn't handle this, so manually patch
the families to replace __ro_after_init with __genl_ro_after_init
which is defined to nothing on kernel version <= 4.9.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
return family->attrbuf;
}
+
+#define __genl_ro_after_init
+#else
+#define __genl_ro_after_init __ro_after_init
#endif
#endif /* __BACKPORT_NET_GENETLINK_H */
--- /dev/null
+--- a/drivers/net/wireless/mac80211_hwsim.c
++++ b/drivers/net/wireless/mac80211_hwsim.c
+@@ -3244,7 +3244,7 @@ static const struct genl_ops hwsim_ops[] = {
+ },
+ };
+
+-static struct genl_family hwsim_genl_family __ro_after_init = {
++static struct genl_family hwsim_genl_family __genl_ro_after_init = {
+ .name = "MAC80211_HWSIM",
+ .version = 1,
+ .maxattr = HWSIM_ATTR_MAX,
--- /dev/null
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -12823,7 +12823,7 @@ static const struct genl_ops nl80211_ops[] = {
+ },
+ };
+
+-static struct genl_family nl80211_fam __ro_after_init = {
++static struct genl_family nl80211_fam __genl_ro_after_init = {
+ .name = NL80211_GENL_NAME, /* have users key off the name instead */
+ .hdrsize = 0, /* no private header */
+ .version = 1, /* no particular meaning now */