public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
@ 2024-10-19 20:16 Javier Carrasco
  2024-10-19 21:59 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Javier Carrasco @ 2024-10-19 20:16 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Walleij
  Cc: netdev, linux-kernel, Javier Carrasco

'ports_fwnode' is initialized via device_get_named_child_node(), which
requires a call to fwnode_handle_put() when the variable is no longer
required to avoid leaking memory.

Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
and is no longer required.

Fixes: 94a2a84f5e9e ("net: dsa: mv88e6xxx: Support LED control")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index da19a3b05549..8c6797af8777 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3379,6 +3379,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
 				break;
 			}
 		}
+		fwnode_handle_put(ports_fwnode);
 	} else {
 		dev_dbg(chip->dev, "no ethernet ports node defined for the device\n");
 	}

---
base-commit: 160a810b2a8588187ec2b1536d0355c0aab8981c
change-id: 20241019-mv88e6xxx_chip-fwnode_handle_put-acc4ed165268

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


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

* Re: [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
  2024-10-19 20:16 [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port() Javier Carrasco
@ 2024-10-19 21:59 ` Andrew Lunn
  2024-10-19 22:21   ` Javier Carrasco
  2024-10-20 17:16 ` Linus Walleij
  2024-10-28 13:30 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2024-10-19 21:59 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Linus Walleij, netdev, linux-kernel

On Sat, Oct 19, 2024 at 10:16:49PM +0200, Javier Carrasco wrote:
> 'ports_fwnode' is initialized via device_get_named_child_node(), which
> requires a call to fwnode_handle_put() when the variable is no longer
> required to avoid leaking memory.
> 
> Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
> and is no longer required.

As you point out, the handle is obtained with
device_get_named_child_node(). It seems odd to use a fwnode_ function
not a device_ function to release the handle. Is there a device_
function?

	Andrew

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

* Re: [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
  2024-10-19 21:59 ` Andrew Lunn
@ 2024-10-19 22:21   ` Javier Carrasco
  2024-10-20 14:47     ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: Javier Carrasco @ 2024-10-19 22:21 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Linus Walleij, netdev, linux-kernel

On 19/10/2024 23:59, Andrew Lunn wrote:
> On Sat, Oct 19, 2024 at 10:16:49PM +0200, Javier Carrasco wrote:
>> 'ports_fwnode' is initialized via device_get_named_child_node(), which
>> requires a call to fwnode_handle_put() when the variable is no longer
>> required to avoid leaking memory.
>>
>> Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
>> and is no longer required.
> 
> As you point out, the handle is obtained with
> device_get_named_child_node(). It seems odd to use a fwnode_ function
> not a device_ function to release the handle. Is there a device_
> function?
> 
> 	Andrew


Hi Andrew,

device_get_named_child_node() receives a pointer to a *device*, and
returns a child node (a pointer to an *fwnode_handle*). That is what has
to be released, and therefore fwnode_handle_put() is the right one.

Note that device_get_named_child_node() documents how to release the
fwnode pointer:

"The caller is responsible for calling fwnode_handle_put() on the
returned fwnode pointer."

Best regards,
Javier Carrasco


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

* Re: [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
  2024-10-19 22:21   ` Javier Carrasco
@ 2024-10-20 14:47     ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-10-20 14:47 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Linus Walleij, netdev, linux-kernel

On Sun, Oct 20, 2024 at 12:21:07AM +0200, Javier Carrasco wrote:
> On 19/10/2024 23:59, Andrew Lunn wrote:
> > On Sat, Oct 19, 2024 at 10:16:49PM +0200, Javier Carrasco wrote:
> >> 'ports_fwnode' is initialized via device_get_named_child_node(), which
> >> requires a call to fwnode_handle_put() when the variable is no longer
> >> required to avoid leaking memory.
> >>
> >> Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
> >> and is no longer required.
> > 
> > As you point out, the handle is obtained with
> > device_get_named_child_node(). It seems odd to use a fwnode_ function
> > not a device_ function to release the handle. Is there a device_
> > function?
> > 
> > 	Andrew
> 
> 
> Hi Andrew,
> 
> device_get_named_child_node() receives a pointer to a *device*, and
> returns a child node (a pointer to an *fwnode_handle*). That is what has
> to be released, and therefore fwnode_handle_put() is the right one.
> 
> Note that device_get_named_child_node() documents how to release the
> fwnode pointer:
> 
> "The caller is responsible for calling fwnode_handle_put() on the
> returned fwnode pointer."

O.K. I just don't like asymmetric APIs. They often lead to bugs, just
look wrong, and make reviewers ask questions...

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

    Andrew

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

* Re: [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
  2024-10-19 20:16 [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port() Javier Carrasco
  2024-10-19 21:59 ` Andrew Lunn
@ 2024-10-20 17:16 ` Linus Walleij
  2024-10-28 13:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2024-10-20 17:16 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Andrew Lunn, Florian Fainelli, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On Sat, Oct 19, 2024 at 10:16 PM Javier Carrasco
<javier.carrasco.cruz@gmail.com> wrote:

> 'ports_fwnode' is initialized via device_get_named_child_node(), which
> requires a call to fwnode_handle_put() when the variable is no longer
> required to avoid leaking memory.
>
> Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
> and is no longer required.
>
> Fixes: 94a2a84f5e9e ("net: dsa: mv88e6xxx: Support LED control")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>

I was as puzzled as Andrew but I buy the explanation.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
  2024-10-19 20:16 [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port() Javier Carrasco
  2024-10-19 21:59 ` Andrew Lunn
  2024-10-20 17:16 ` Linus Walleij
@ 2024-10-28 13:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-28 13:30 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: andrew, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
	linus.walleij, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Sat, 19 Oct 2024 22:16:49 +0200 you wrote:
> 'ports_fwnode' is initialized via device_get_named_child_node(), which
> requires a call to fwnode_handle_put() when the variable is no longer
> required to avoid leaking memory.
> 
> Add the missing fwnode_handle_put() after 'ports_fwnode' has been used
> and is no longer required.
> 
> [...]

Here is the summary with links:
  - [net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port()
    https://git.kernel.org/netdev/net-next/c/b8ee7a11c754

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] 6+ messages in thread

end of thread, other threads:[~2024-10-28 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-19 20:16 [PATCH net-next] net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port() Javier Carrasco
2024-10-19 21:59 ` Andrew Lunn
2024-10-19 22:21   ` Javier Carrasco
2024-10-20 14:47     ` Andrew Lunn
2024-10-20 17:16 ` Linus Walleij
2024-10-28 13: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