Linux backports project
 help / color / mirror / Atom feed
* [PATCH] backport: handle change in netdevice destructor usage
@ 2017-06-12  9:06 Arend van Spriel
  2017-06-12  9:11 ` Johannes Berg
  2017-06-13 20:59 ` Johannes Berg
  0 siblings, 2 replies; 9+ messages in thread
From: Arend van Spriel @ 2017-06-12  9:06 UTC (permalink / raw)
  To: Johannes Berg; +Cc: backports, Arend van Spriel

This patch deals with changes made in struct net_device by commit
cf124db566e6 ("net: Fix inconsistent teardown and release of private
netdev state."). This only looks for instances that need free_netdev()
call, ie. struct net_device::needs_free_netdev == true.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
 backport/backport-include/linux/netdevice.h | 12 +++++++++++
 patches/0079-netdev-destructor.cocci        | 33 +++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 patches/0079-netdev-destructor.cocci

diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h
index 06230b5..4e30383 100644
--- a/backport/backport-include/linux/netdevice.h
+++ b/backport/backport-include/linux/netdevice.h
@@ -320,4 +320,16 @@ static inline void netif_trans_update(struct net_device *dev)
 }
 #endif
 
+static inline
+void netdev_set_priv_destructor(struct net_device *dev,
+				void (*destructor)(struct net_device *dev))
+{
+#if LINUX_VERSION_IS_LESS(4,12,0)
+	dev->destructor = destructor;
+#else
+	dev->needs_free_netdev = true;
+	dev->priv_destructor = destructor;
+#endif
+}
+
 #endif /* __BACKPORT_NETDEVICE_H */
diff --git a/patches/0079-netdev-destructor.cocci b/patches/0079-netdev-destructor.cocci
new file mode 100644
index 0000000..d8a439d
--- /dev/null
+++ b/patches/0079-netdev-destructor.cocci
@@ -0,0 +1,33 @@
+@r1@
+struct net_device *ndev;
+identifier D, C;
+@@
+C(...)
+{
+	<...
+-	ndev->needs_free_netdev = true;
+-	ndev->priv_destructor = D;
++	netdev_set_priv_destructor(ndev, D);
+	...>
+}
+
+@r2 depends on r1@
+struct net_device *NDEV;
+identifier r1.D;
+identifier r1.C;
+fresh identifier E2 = "__" ## D;
+@@
+
++static void E2(struct net_device *dev)
++{
++	D(dev);
++	free_netdev(dev);
++}
++
+C(...)
+{
+	<...
+-	netdev_set_priv_destructor(NDEV, D);
++	netdev_set_priv_destructor(NDEV, E2);
+	...>
+}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-06-14 20:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-12  9:06 [PATCH] backport: handle change in netdevice destructor usage Arend van Spriel
2017-06-12  9:11 ` Johannes Berg
2017-06-12  9:15   ` Arend van Spriel
2017-06-12  9:22     ` Johannes Berg
2017-06-13 20:59 ` Johannes Berg
2017-06-14 13:25   ` Arend van Spriel
2017-06-14 13:26     ` Johannes Berg
2017-06-14 17:28       ` Arend van Spriel
2017-06-14 20:22         ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox