summaryrefslogtreecommitdiff
path: root/patches/0079-netdev-destructor.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'patches/0079-netdev-destructor.cocci')
-rw-r--r--patches/0079-netdev-destructor.cocci84
1 files changed, 84 insertions, 0 deletions
diff --git a/patches/0079-netdev-destructor.cocci b/patches/0079-netdev-destructor.cocci
new file mode 100644
index 00000000..fab8af19
--- /dev/null
+++ b/patches/0079-netdev-destructor.cocci
@@ -0,0 +1,84 @@
+@r1@
+struct net_device *NDEV;
+identifier D, C;
+identifier TRUE =~ "true";
+@@
+C(...)
+{
+ <...
+- NDEV->needs_free_netdev = TRUE;
+- NDEV->priv_destructor = D;
++ netdev_set_priv_destructor(NDEV, D);
+ ...>
+}
+
+@r2 depends on r1@
+identifier r1.D, r1.C;
+fresh identifier E = "__" ## D;
+@@
+
++#if LINUX_VERSION_IS_LESS(4,13,0)
++static void E(struct net_device *ndev)
++{
++ D(ndev);
++ free_netdev(ndev);
++}
++#endif
++
+C(...)
+{
+ ...
+}
+
+@r3 depends on r1@
+type T;
+identifier NDEV;
+identifier r1.D;
+T RET;
+@@
+
+RET = \(register_netdevice\|register_ndev\)(NDEV);
+if (<+... RET ...+>) {
+ <...
++#if LINUX_VERSION_IS_LESS(4,13,0)
++ D(NDEV);
++#endif
+ free_netdev(NDEV);
+ ...>
+}
+
+@r4 depends on r1@
+identifier NDEV;
+identifier r1.D;
+type T;
+T RET;
+@@
+
+if (...)
+ RET = register_netdevice(NDEV);
+else
+ RET = register_netdev(NDEV);
+if (<+... RET ...+>) {
+ <...
++#if LINUX_VERSION_IS_LESS(4,13,0)
++ D(NDEV);
++#endif
+ free_netdev(NDEV);
+ ...>
+}
+
+@r5@
+struct net_device *NDEV;
+identifier TRUE =~ "true";
+@@
+
+-NDEV->needs_free_netdev = TRUE;
++netdev_set_priv_destructor(NDEV, free_netdev);
+
+@r6@
+struct net_device *NDEV;
+identifier D;
+@@
+
+-NDEV->priv_destructor = D;
++netdev_set_priv_destructor(NDEV, D);