History

net: phy: leds: Fix truncated LED trigger names

Commit 4567d686f5c6d955 ("phy: increase size of MII_BUS_ID_SIZE and bus_id") increased the size of MII bus IDs, but forgot to update the private definition in <linux/phy_led_triggers.h>. This may cause: 1. Truncation of LED trigger names, 2. Duplicate LED trigger names, 3. Failures registering LED triggers, 4. Crashes due to bad error handling in the LED trigger failure path. To fix this, and prevent the definitions going out of sync again in the future, let the PHY LED trigger code use the existing MII_BUS_ID_SIZE definition. Example: - Before I had triggers "ee700000.etherne:01:100Mbps" and "ee700000.etherne:01:10Mbps", - After the increase of MII_BUS_ID_SIZE, both became "ee700000.ethernet-ffffffff:01:" => FAIL, - Now, the triggers are "ee700000.ethernet-ffffffff:01:100Mbps" and "ee700000.ethernet-ffffffff:01:10Mbps", which are unique again.

Geert Uytterhoeven committed 9 years ago

Commit 3c880eb1 parent d6f8cfa1 file · +2 −2Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/phy_led_triggers.h+2−2
@@ -18,11 +18,11 @@ struct phy_device; · 17 unmodified lines
1818 #ifdef CONFIG_LED_TRIGGER_PHY
1919
2020 #include <linux/leds.h>
21+#include <linux/phy.h>
2122
2223 #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10
23−#define PHY_MII_BUS_ID_SIZE (20 - 3)
2424
25−#define PHY_LINK_LED_TRIGGER_NAME_SIZE (PHY_MII_BUS_ID_SIZE + \
25+#define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \
2626 FIELD_SIZEOF(struct mdio_device, addr)+\
2727 PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE)
2828