linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] net: airoha: Fix an error handling path in airoha_alloc_gdm_port()
@ 2025-05-08 14:52 Christophe JAILLET
  2025-05-08 14:52 ` [PATCH v2 2/4] net: airoha: Fix an error handling path in airoha_probe() Christophe JAILLET
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Christophe JAILLET @ 2025-05-08 14:52 UTC (permalink / raw)
  To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
	linux-arm-kernel, linux-mediatek, netdev

If register_netdev() fails, the error handling path of the probe will not
free the memory allocated by the previous airoha_metadata_dst_alloc() call
because port->dev->reg_state will not be NETREG_REGISTERED.

So, an explicit airoha_metadata_dst_free() call is needed in this case to
avoid a memory leak.

Fixes: af3cf757d5c9 ("net: airoha: Move DSA tag in DMA descriptor")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Changes in v2:
  - New patch

Compile tested only.
---
 drivers/net/ethernet/airoha/airoha_eth.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
index 16c7896f931f..af8c4015938c 100644
--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -2873,7 +2873,15 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth,
 	if (err)
 		return err;
 
-	return register_netdev(dev);
+	err = register_netdev(dev);
+	if (err)
+		goto free_metadata_dst;
+
+	return 0;
+
+free_metadata_dst:
+	airoha_metadata_dst_free(port);
+	return err;
 }
 
 static int airoha_probe(struct platform_device *pdev)
-- 
2.49.0



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

end of thread, other threads:[~2025-05-10  8:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 14:52 [PATCH v2 1/4] net: airoha: Fix an error handling path in airoha_alloc_gdm_port() Christophe JAILLET
2025-05-08 14:52 ` [PATCH v2 2/4] net: airoha: Fix an error handling path in airoha_probe() Christophe JAILLET
2025-05-08 15:10   ` Lorenzo Bianconi
2025-05-08 15:21     ` Christophe JAILLET
2025-05-08 14:52 ` [PATCH v2 3/4] net: airoha: Use for_each_child_of_node_scoped() Christophe JAILLET
2025-05-08 14:52 ` [PATCH v2 4/4] net: airoha: Use dev_err_probe() Christophe JAILLET
2025-05-08 15:43   ` Lorenzo Bianconi
2025-05-08 16:00     ` Christophe JAILLET
2025-05-08 15:31 ` [PATCH v2 1/4] net: airoha: Fix an error handling path in airoha_alloc_gdm_port() Lorenzo Bianconi
2025-05-08 16:05   ` Christophe JAILLET
2025-05-10  8:20     ` Lorenzo Bianconi

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).