Skip to content

Commit cff865c

Browse files
arndbkuba-moo
authored andcommitted
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: 1758af4 ("net: phy: intel-xway: add support for PHY LEDs") Fixes: 9d55e68 ("net: phy: aquantia: correctly describe LED polarity override") Fixes: eb89c79 ("net: phy: mxl-gpy: correctly describe LED polarity") Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 954a2b4 commit cff865c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

drivers/net/phy/aquantia/aquantia_leds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,5 @@ int aqr_phy_led_polarity_set(struct phy_device *phydev, int index, unsigned long
156156
if (force_active_high || force_active_low)
157157
return aqr_phy_led_active_low_set(phydev, index, force_active_low);
158158

159-
unreachable();
159+
return -EINVAL;
160160
}

drivers/net/phy/intel-xway.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static int xway_gphy_led_polarity_set(struct phy_device *phydev, int index,
529529
if (force_active_high)
530530
return phy_clear_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_INV(index));
531531

532-
unreachable();
532+
return -EINVAL;
533533
}
534534

535535
static struct phy_driver xway_gphy[] = {

drivers/net/phy/mxl-gpy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ static int gpy_led_polarity_set(struct phy_device *phydev, int index,
10141014
if (force_active_high)
10151015
return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index));
10161016

1017-
unreachable();
1017+
return -EINVAL;
10181018
}
10191019

10201020
static struct phy_driver gpy_drivers[] = {

0 commit comments

Comments
 (0)