Skip to content

Commit c597837

Browse files
tititiou36kuba-moo
authored andcommitted
net: airoha: Fix an error handling path in airoha_alloc_gdm_port()
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: af3cf75 ("net: airoha: Move DSA tag in DMA descriptor") Signed-off-by: Christophe JAILLET <[email protected]> Acked-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/1b94b91345017429ed653e2f05d25620dc2823f9.1746715755.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0795b05 commit c597837

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,15 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth,
25412541
if (err)
25422542
return err;
25432543

2544-
return register_netdev(dev);
2544+
err = register_netdev(dev);
2545+
if (err)
2546+
goto free_metadata_dst;
2547+
2548+
return 0;
2549+
2550+
free_metadata_dst:
2551+
airoha_metadata_dst_free(port);
2552+
return err;
25452553
}
25462554

25472555
static int airoha_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)