Fix leaking can_netdev device from failed to get phy during m_can_plat_probe(), 
to
avoid below kmemleak call trace:

unreferenced object 0xfffffc08262d4e00 (size 512):
comm "kworker/1:1", pid 29, jiffies 4294893754 (age 393.056s)
hex dump (first 32 bytes):
00 80 31 25 08 fc ff ff 00 00 00 00 00 00 00 00 ..1%............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000006019c2e>] __kmalloc+0x208/0x530
[<000000001c5298c4>] kvmalloc_node+0x4c/0xf0
[<0000000016401679>] alloc_netdev_mqs+0x1a8/0x3a0
[<000000001061bcab>] alloc_candev_mqs+0x68/0x150
[<00000000b7e7f5ec>] m_can_class_allocate_dev+0x64/0x190
[<0000000011b0e0eb>] m_can_plat_probe+0x34/0x1f0
[<00000000a93b1ad6>] platform_drv_probe+0x60/0xb4
[<0000000077f492cb>] really_probe+0xf0/0x4d0
[<000000000bba45b5>] driver_probe_device+0x64/0xcc
[<00000000f7a68dc2>] __device_attach_driver+0xb4/0x110
[<0000000079312056>] bus_for_each_drv+0x84/0xd4
[<0000000095d132d1>] __device_attach+0xe0/0x180
[<000000009dcc93b7>] device_initial_probe+0x20/0x30
[<0000000046583ae6>] bus_probe_device+0xa4/0xb0
[<0000000035e3108c>] deferred_probe_work_func+0x94/0xcc
[<000000008afbe59d>] process_one_work+0x1f0/0x4b0

Signed-off-by: Xulin Sun <xulin....@windriver.com>
---
 drivers/net/can/m_can/m_can_platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can_platform.c 
b/drivers/net/can/m_can/m_can_platform.c
index 45910fb5145c..dbebb9bba545 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -105,7 +105,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
        if (IS_ERR(transceiver)) {
                ret = PTR_ERR(transceiver);
                dev_err_probe(&pdev->dev, ret, "failed to get phy\n");
-               return ret;
+               goto probe_fail;
        }
 
        if (transceiver)
-- 
2.17.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#10450): 
https://lists.yoctoproject.org/g/linux-yocto/message/10450
Mute This Topic: https://lists.yoctoproject.org/mt/85832833/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to