netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode
@ 2025-08-30  9:18 Miaoqian Lin
  2025-09-01 15:00 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Miaoqian Lin @ 2025-08-30  9:18 UTC (permalink / raw)
  To: Marcin Wojtas, Russell King, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: linmq006

The function calls fwnode_get_named_child_node()
to check for a "fixed-link" child.
It did not release the reference if present, causing a refcount leak.

Fixes: dfce1bab8fdc ("net: mvpp2: enable using phylink with ACPI")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 8ebb985d2573..1faed2ec3f4f 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -6801,12 +6801,22 @@ static void mvpp2_acpi_start(struct mvpp2_port *port)
  */
 static bool mvpp2_use_acpi_compat_mode(struct fwnode_handle *port_fwnode)
 {
+	struct fwnode_handle *fixed_link;
+
 	if (!is_acpi_node(port_fwnode))
 		return false;
 
-	return (!fwnode_property_present(port_fwnode, "phy-handle") &&
-		!fwnode_property_present(port_fwnode, "managed") &&
-		!fwnode_get_named_child_node(port_fwnode, "fixed-link"));
+	if (fwnode_property_present(port_fwnode, "phy-handle") ||
+	    fwnode_property_present(port_fwnode, "managed"))
+		return false;
+
+	fixed_link = fwnode_get_named_child_node(port_fwnode, "fixed-link");
+	if (fixed_link) {
+		fwnode_handle_put(fixed_link);
+		return false;
+	}
+
+	return true;
 }
 
 /* Ports initialization */
-- 
2.35.1


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

* Re: [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode
  2025-08-30  9:18 [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode Miaoqian Lin
@ 2025-09-01 15:00 ` Simon Horman
  2025-09-01 19:50 ` Jakub Kicinski
  2025-09-02 14:09 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-09-01 15:00 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Marcin Wojtas, Russell King, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On Sat, Aug 30, 2025 at 05:18:54PM +0800, Miaoqian Lin wrote:
> The function calls fwnode_get_named_child_node()
> to check for a "fixed-link" child.
> It did not release the reference if present, causing a refcount leak.
> 
> Fixes: dfce1bab8fdc ("net: mvpp2: enable using phylink with ACPI")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Probably this should be targeted at the net tree, like this

Subject: [PATCH net] ...

But that notwithstanding, this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

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

* Re: [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode
  2025-08-30  9:18 [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode Miaoqian Lin
  2025-09-01 15:00 ` Simon Horman
@ 2025-09-01 19:50 ` Jakub Kicinski
  2025-09-02 14:09 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-09-01 19:50 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Marcin Wojtas, Russell King, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, linux-kernel

On Sat, 30 Aug 2025 17:18:54 +0800 Miaoqian Lin wrote:
> -	return (!fwnode_property_present(port_fwnode, "phy-handle") &&
> -		!fwnode_property_present(port_fwnode, "managed") &&
> -		!fwnode_get_named_child_node(port_fwnode, "fixed-link"));
> +	if (fwnode_property_present(port_fwnode, "phy-handle") ||
> +	    fwnode_property_present(port_fwnode, "managed"))
> +		return false;
> +
> +	fixed_link = fwnode_get_named_child_node(port_fwnode, "fixed-link");

Wouldn't it be easier to switch to fwnode_get_named_child_node_count() ?
-- 
pw-bot: cr

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

* Re: [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode
  2025-08-30  9:18 [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode Miaoqian Lin
  2025-09-01 15:00 ` Simon Horman
  2025-09-01 19:50 ` Jakub Kicinski
@ 2025-09-02 14:09 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-09-02 14:09 UTC (permalink / raw)
  To: Miaoqian Lin, netdev
  Cc: LKML, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Marcin Wojtas, Paolo Abeni, Russell King, Simon Horman

…
> It did not release the reference if present, causing a refcount leak.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n94

Regards,
Markus

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

end of thread, other threads:[~2025-09-02 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-30  9:18 [PATCH] net: mvpp2: Fix refcount leak in mvpp2_use_acpi_compat_mode Miaoqian Lin
2025-09-01 15:00 ` Simon Horman
2025-09-01 19:50 ` Jakub Kicinski
2025-09-02 14:09 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).