aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorWill Moss <willormos@gmail.com>2022-08-03 13:56:28 +0000
committerChristian Marangi <ansuelsmth@gmail.com>2022-09-23 12:16:29 +0200
commita24e07700d0f884ff82e565110adef4ad2155db4 (patch)
tree9368fe43cfcd275df9bb29e829c7c2d0c4bfd226 /target/linux
parenta6fd151308b1ad1878ba367549a9e9ef5c717653 (diff)
downloadupstream-a24e07700d0f884ff82e565110adef4ad2155db4.tar.gz
upstream-a24e07700d0f884ff82e565110adef4ad2155db4.tar.bz2
upstream-a24e07700d0f884ff82e565110adef4ad2155db4.zip
kernel: fix mac-address-increment on driver probe defer
Fixes situations where MAC address gets incremented multiple times if device initialization fails at first and then is deferred. Fixes: d284e6ef0f06 ("treewide: convert mtd-mac-address-increment* to generic implementation") Signed-off-by: Will Moss <willormos@gmail.com>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/generic/pending-5.10/684-of_net-do-mac-address-increment-only-once.patch31
-rw-r--r--target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch31
2 files changed, 62 insertions, 0 deletions
diff --git a/target/linux/generic/pending-5.10/684-of_net-do-mac-address-increment-only-once.patch b/target/linux/generic/pending-5.10/684-of_net-do-mac-address-increment-only-once.patch
new file mode 100644
index 0000000000..b1c5d9112a
--- /dev/null
+++ b/target/linux/generic/pending-5.10/684-of_net-do-mac-address-increment-only-once.patch
@@ -0,0 +1,31 @@
+From dd07dd394d8bfdb5d527fab18ca54f20815ec4e4 Mon Sep 17 00:00:00 2001
+From: Will Moss <willormos@gmail.com>
+Date: Wed, 3 Aug 2022 13:48:55 +0000
+Subject: [PATCH] of_net: do mac-address-increment only once
+
+Remove mac-address-increment and mac-address-increment-byte
+DT property after incrementing process to make sure MAC address
+would not get incremented more if this function is stared again.
+It could happen if device initialization is deferred after
+unsuccessful attempt.
+
+Signed-off-by: Will Moss <willormos@gmail.com>
+---
+ drivers/of/of_net.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/of/of_net.c
++++ b/drivers/of/of_net.c
+@@ -190,6 +190,12 @@ found:
+ addr[3] = (mac_val >> 16) & 0xff;
+ addr[4] = (mac_val >> 8) & 0xff;
+ addr[5] = (mac_val >> 0) & 0xff;
++
++ /* Remove mac-address-increment and mac-address-increment-byte
++ * DT property to make sure MAC address would not get incremented
++ * more if this function is stared again. */
++ of_remove_property(np, of_find_property(np, "mac-address-increment", NULL));
++ of_remove_property(np, of_find_property(np, "mac-address-increment-byte", NULL));
+ }
+
+ of_add_mac_address(np, addr);
diff --git a/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch b/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch
new file mode 100644
index 0000000000..44d88e31a2
--- /dev/null
+++ b/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch
@@ -0,0 +1,31 @@
+From dd07dd394d8bfdb5d527fab18ca54f20815ec4e4 Mon Sep 17 00:00:00 2001
+From: Will Moss <willormos@gmail.com>
+Date: Wed, 3 Aug 2022 13:48:55 +0000
+Subject: [PATCH] of_net: do mac-address-increment only once
+
+Remove mac-address-increment and mac-address-increment-byte
+DT property after incrementing process to make sure MAC address
+would not get incremented more if this function is stared again.
+It could happen if device initialization is deferred after
+unsuccessful attempt.
+
+Signed-off-by: Will Moss <willormos@gmail.com>
+---
+ drivers/of/of_net.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/net/core/of_net.c
++++ b/net/core/of_net.c
+@@ -194,6 +194,12 @@ found:
+ addr[3] = (mac_val >> 16) & 0xff;
+ addr[4] = (mac_val >> 8) & 0xff;
+ addr[5] = (mac_val >> 0) & 0xff;
++
++ /* Remove mac-address-increment and mac-address-increment-byte
++ * DT property to make sure MAC address would not get incremented
++ * more if this function is stared again. */
++ of_remove_property(np, of_find_property(np, "mac-address-increment", NULL));
++ of_remove_property(np, of_find_property(np, "mac-address-increment-byte", NULL));
+ }
+
+ of_add_mac_address(np, addr);