Skip to content

Commit 0baa4d3

Browse files
GoodLuck612marckleinebudde
authored andcommitted
can: at91_can: Fix memory leak in at91_can_probe()
In at91_can_probe(), the dev structure is allocated via alloc_candev(). However, if the subsequent call to devm_phy_optional_get() fails, the code jumps directly to exit_iounmap, missing the call to free_candev(). This results in a memory leak of the allocated net_device structure. Fix this by jumping to the exit_free label instead, which ensures that free_candev() is called to properly release the memory. Compile tested only. Issue found using a prototype static analysis tool and code review. Fixes: 3ecc098 ("can: at91_can: add CAN transceiver support") Signed-off-by: Zilin Guan <zilin@seu.edu.cn> Link: https://patch.msgid.link/20260122114128.643752-1-zilin@seu.edu.cn Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 5778d65 commit 0baa4d3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/can/at91_can.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ static int at91_can_probe(struct platform_device *pdev)
10991099
if (IS_ERR(transceiver)) {
11001100
err = PTR_ERR(transceiver);
11011101
dev_err_probe(&pdev->dev, err, "failed to get phy\n");
1102-
goto exit_iounmap;
1102+
goto exit_free;
11031103
}
11041104

11051105
dev->netdev_ops = &at91_netdev_ops;

0 commit comments

Comments
 (0)