public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property
@ 2023-04-24 14:16 Alexander Stein
  2023-04-24 16:30 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Stein @ 2023-04-24 14:16 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli,
	Christian Marangi
  Cc: Alexander Stein, netdev

'reg' is always encoded in 32 bits, thus it has to be read using the
function with the corresponding bit width.

Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
Signed-off-by: Alexander Stein <alexander.stein@ew•tq-group.com>
---
Changes in v2:
* Explicitly do range check before assigning to u8

 drivers/net/phy/phy_device.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index d373446ab5ac..17d0d0555a79 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3028,6 +3028,7 @@ static int of_phy_led(struct phy_device *phydev,
 	struct led_init_data init_data = {};
 	struct led_classdev *cdev;
 	struct phy_led *phyled;
+	u32 index;
 	int err;
 
 	phyled = devm_kzalloc(dev, sizeof(*phyled), GFP_KERNEL);
@@ -3037,10 +3038,13 @@ static int of_phy_led(struct phy_device *phydev,
 	cdev = &phyled->led_cdev;
 	phyled->phydev = phydev;
 
-	err = of_property_read_u8(led, "reg", &phyled->index);
+	err = of_property_read_u32(led, "reg", &index);
 	if (err)
 		return err;
+	if (index > U8_MAX)
+		return -EINVAL;
 
+	phyled->index = index;
 	if (phydev->drv->led_brightness_set)
 		cdev->brightness_set_blocking = phy_led_set_brightness;
 	if (phydev->drv->led_blink_set)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property
  2023-04-24 14:16 [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property Alexander Stein
@ 2023-04-24 16:30 ` Andrew Lunn
  2023-04-24 18:12 ` Florian Fainelli
  2023-04-25  1:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2023-04-24 16:30 UTC (permalink / raw)
  To: Alexander Stein
  Cc: Heiner Kallweit, Russell King, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Florian Fainelli, Christian Marangi,
	netdev

On Mon, Apr 24, 2023 at 04:16:48PM +0200, Alexander Stein wrote:
> 'reg' is always encoded in 32 bits, thus it has to be read using the
> function with the corresponding bit width.
> 
> Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
> Signed-off-by: Alexander Stein <alexander.stein@ew•tq-group.com>

Reviewed-by: Andrew Lunn <andrew@lunn•ch>

    Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property
  2023-04-24 14:16 [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property Alexander Stein
  2023-04-24 16:30 ` Andrew Lunn
@ 2023-04-24 18:12 ` Florian Fainelli
  2023-04-25  1:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2023-04-24 18:12 UTC (permalink / raw)
  To: Alexander Stein, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Christian Marangi
  Cc: netdev

On 4/24/23 07:16, Alexander Stein wrote:
> 'reg' is always encoded in 32 bits, thus it has to be read using the
> function with the corresponding bit width.
> 
> Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
> Signed-off-by: Alexander Stein <alexander.stein@ew•tq-group.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail•com>
-- 
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property
  2023-04-24 14:16 [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property Alexander Stein
  2023-04-24 16:30 ` Andrew Lunn
  2023-04-24 18:12 ` Florian Fainelli
@ 2023-04-25  1:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-25  1:30 UTC (permalink / raw)
  To: Alexander Stein
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	f.fainelli, ansuelsmth, netdev

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel•org>:

On Mon, 24 Apr 2023 16:16:48 +0200 you wrote:
> 'reg' is always encoded in 32 bits, thus it has to be read using the
> function with the corresponding bit width.
> 
> Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
> Signed-off-by: Alexander Stein <alexander.stein@ew•tq-group.com>
> ---
> Changes in v2:
> * Explicitly do range check before assigning to u8
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/1] net: phy: Fix reading LED reg property
    https://git.kernel.org/netdev/net-next/c/aed8fdad2152

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-25  1:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-24 14:16 [PATCH net-next v2 1/1] net: phy: Fix reading LED reg property Alexander Stein
2023-04-24 16:30 ` Andrew Lunn
2023-04-24 18:12 ` Florian Fainelli
2023-04-25  1:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox