Skip to content

Commit aed8fda

Browse files
tq-steinakuba-moo
authored andcommitted
net: phy: Fix reading LED reg property
'reg' is always encoded in 32 bits, thus it has to be read using the function with the corresponding bit width. Fixes: 01e5b72 ("net: phy: Add a binding for PHY LEDs") Signed-off-by: Alexander Stein <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e515c33 commit aed8fda

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/net/phy/phy_device.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,7 @@ static int of_phy_led(struct phy_device *phydev,
30283028
struct led_init_data init_data = {};
30293029
struct led_classdev *cdev;
30303030
struct phy_led *phyled;
3031+
u32 index;
30313032
int err;
30323033

30333034
phyled = devm_kzalloc(dev, sizeof(*phyled), GFP_KERNEL);
@@ -3037,10 +3038,13 @@ static int of_phy_led(struct phy_device *phydev,
30373038
cdev = &phyled->led_cdev;
30383039
phyled->phydev = phydev;
30393040

3040-
err = of_property_read_u8(led, "reg", &phyled->index);
3041+
err = of_property_read_u32(led, "reg", &index);
30413042
if (err)
30423043
return err;
3044+
if (index > U8_MAX)
3045+
return -EINVAL;
30433046

3047+
phyled->index = index;
30443048
if (phydev->drv->led_brightness_set)
30453049
cdev->brightness_set_blocking = phy_led_set_brightness;
30463050
if (phydev->drv->led_blink_set)

0 commit comments

Comments
 (0)