[openwrt/openwrt] kernel: PHY: backport led fixes commit

LEDE Commits lede-commits at lists.infradead.org
Sun Jan 4 15:24:44 PST 2026


hauke pushed a commit to openwrt/openwrt.git, branch openwrt-25.12:
https://git.openwrt.org/301515ab7d025cdd2badb7bc43c9f50afe272ea6

commit 301515ab7d025cdd2badb7bc43c9f50afe272ea6
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Thu Jan 1 17:34:05 2026 +0100

    kernel: PHY: backport led fixes commit
    
    This patch fixes a bug in some patches we backported.
    
    This patch was cherry picked from upstream Linux because it references a
    patch we backported in the fixes tag.
    
    Link: https://github.com/openwrt/openwrt/pull/21366
    (cherry picked from commit 63b45a10c0371429a8e2d993dfe155ef3bd802b1)
    Link: https://github.com/openwrt/openwrt/pull/21390
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 ...id-undefined-behavior-in-_led_polarity_se.patch | 64 ++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/target/linux/generic/backport-6.12/735-v6.13-net-phy-avoid-undefined-behavior-in-_led_polarity_se.patch b/target/linux/generic/backport-6.12/735-v6.13-net-phy-avoid-undefined-behavior-in-_led_polarity_se.patch
new file mode 100644
index 0000000000..7a1553ae28
--- /dev/null
+++ b/target/linux/generic/backport-6.12/735-v6.13-net-phy-avoid-undefined-behavior-in-_led_polarity_se.patch
@@ -0,0 +1,64 @@
+From cff865c700711ecc3824b2dfe181637f3ed23c80 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd at arndb.de>
+Date: Tue, 17 Dec 2024 09:10:34 +0100
+Subject: net: phy: avoid undefined behavior in *_led_polarity_set()
+
+gcc runs into undefined behavior at the end of the three led_polarity_set()
+callback functions if it were called with a zero 'modes' argument and it
+just ends the function there without returning from it.
+
+This gets flagged by 'objtool' as a function that continues on
+to the next one:
+
+drivers/net/phy/aquantia/aquantia_leds.o: warning: objtool: aqr_phy_led_polarity_set+0xf: can't find jump dest instruction at .text+0x5d9
+drivers/net/phy/intel-xway.o: warning: objtool: xway_gphy_led_polarity_set() falls through to next function xway_gphy_config_init()
+drivers/net/phy/mxl-gpy.o: warning: objtool: gpy_led_polarity_set() falls through to next function gpy_led_hw_control_get()
+
+There is no point to micro-optimize the behavior here to save a single-digit
+number of bytes in the kernel, so just change this to a "return -EINVAL"
+as we do when any unexpected bits are set.
+
+Fixes: 1758af47b98c ("net: phy: intel-xway: add support for PHY LEDs")
+Fixes: 9d55e68b19f2 ("net: phy: aquantia: correctly describe LED polarity override")
+Fixes: eb89c79c1b8f ("net: phy: mxl-gpy: correctly describe LED polarity")
+Signed-off-by: Arnd Bergmann <arnd at arndb.de>
+Reviewed-by: Andrew Lunn <andrew at lunn.ch>
+Link: https://patch.msgid.link/20241217081056.238792-1-arnd@kernel.org
+Signed-off-by: Jakub Kicinski <kuba at kernel.org>
+---
+ drivers/net/phy/aquantia/aquantia_leds.c | 2 +-
+ drivers/net/phy/intel-xway.c             | 2 +-
+ drivers/net/phy/mxl-gpy.c                | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/phy/aquantia/aquantia_leds.c
++++ b/drivers/net/phy/aquantia/aquantia_leds.c
+@@ -156,5 +156,5 @@ int aqr_phy_led_polarity_set(struct phy_
+ 	if (force_active_high || force_active_low)
+ 		return aqr_phy_led_active_low_set(phydev, index, force_active_low);
+ 
+-	unreachable();
++	return -EINVAL;
+ }
+--- a/drivers/net/phy/intel-xway.c
++++ b/drivers/net/phy/intel-xway.c
+@@ -529,7 +529,7 @@ static int xway_gphy_led_polarity_set(st
+ 	if (force_active_high)
+ 		return phy_clear_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_INV(index));
+ 
+-	unreachable();
++	return -EINVAL;
+ }
+ 
+ static struct phy_driver xway_gphy[] = {
+--- a/drivers/net/phy/mxl-gpy.c
++++ b/drivers/net/phy/mxl-gpy.c
+@@ -1014,7 +1014,7 @@ static int gpy_led_polarity_set(struct p
+ 	if (force_active_high)
+ 		return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index));
+ 
+-	unreachable();
++	return -EINVAL;
+ }
+ 
+ static struct phy_driver gpy_drivers[] = {




More information about the lede-commits mailing list