[PATCH] can: at91_can: fix an error handle in at91_can_probe()

Haoxiang Li posted 1 patch 1 week, 5 days ago
drivers/net/can/at91_can.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] can: at91_can: fix an error handle in at91_can_probe()
Posted by Haoxiang Li 1 week, 5 days ago
In at91_can_probe(), if devm_phy_optional_get() fails,
the memory allocated by alloc_candev() should be freed.
Modify the goto label to do so.

Fixes: 3ecc09856afb ("can: at91_can: add CAN transceiver support")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/net/can/at91_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index c2a3a4eef5b2..58da323f14d7 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1099,7 +1099,7 @@ static int at91_can_probe(struct platform_device *pdev)
 	if (IS_ERR(transceiver)) {
 		err = PTR_ERR(transceiver);
 		dev_err_probe(&pdev->dev, err, "failed to get phy\n");
-		goto exit_iounmap;
+		goto exit_free;
 	}
 
 	dev->netdev_ops	= &at91_netdev_ops;
-- 
2.25.1
Re: [PATCH] can: at91_can: fix an error handle in at91_can_probe()
Posted by Marc Kleine-Budde 1 week, 5 days ago
On 25.01.2026 20:09:47, Haoxiang Li wrote:
> In at91_can_probe(), if devm_phy_optional_get() fails,
> the memory allocated by alloc_candev() should be freed.
> Modify the goto label to do so.
>
> Fixes: 3ecc09856afb ("can: at91_can: add CAN transceiver support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>

A similar patch has just been reported, see:
https://lore.kernel.org/all/20260122114128.643752-1-zilin@seu.edu.cn/

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |