When testing FMI feature with below command tsntool qcifmiget --device eth0 --index 2 There is a memory leak occurring as below unreferenced object 0xffff00000047e200 (size 128): comm "tsntool", pid 444, jiffies 4294931230 (age 17.688s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000a1f46be5>] kmem_cache_alloc_trace+0x3e8/0x680 [<0000000034f0835f>] enetc_qci_fmi_get+0x174/0x294 [<00000000c8de8870>] cmd_qci_fmi_get.isra.0+0xb8/0x390 [<00000000a5923a36>] tsn_qci_fmi_get+0x28/0x40 [<0000000016a765c0>] genl_family_rcv_msg_doit+0xd0/0x15c [<00000000468e65a1>] genl_rcv_msg+0xec/0x1f0 [<00000000a002deef>] netlink_rcv_skb+0x64/0x130 [<0000000063fa81de>] genl_rcv+0x40/0x60 [<0000000071bbebf2>] netlink_unicast+0x230/0x310 [<000000005fb3fad1>] netlink_sendmsg+0x1bc/0x400 [<000000008ac52897>] __sys_sendto+0xd4/0x12c [<00000000252525f3>] __arm64_sys_sendto+0x30/0x40 [<000000000d993fdc>] invoke_syscall+0x5c/0x130 [<0000000092b245b4>] el0_svc_common.constprop.0+0x4c/0x100 [<000000008829e8f3>] do_el0_svc+0x4c/0xb4 [<000000006bebec28>] el0_svc+0x28/0x80 Because the fmi_counter_data is not freed after it is used. In additional, refer to other functions, unmap DMA, and clear cbdr to 0 after it is used.
Signed-off-by: Meng Li <meng...@windriver.com> --- drivers/net/ethernet/freescale/enetc/enetc_tsn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_tsn.c b/drivers/net/ethernet/freescale/enetc/enetc_tsn.c index 5ff36647be84..f087f0b5e340 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_tsn.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_tsn.c @@ -1533,6 +1533,10 @@ static int enetc_qci_fmi_get(struct net_device *ndev, u32 index, memcpy(counters, fmi_counter_data, sizeof(*counters)); + dma_unmap_single(&priv->si->pdev->dev, dma, data_size, DMA_FROM_DEVICE); + memset(cbdr, 0, sizeof(*cbdr)); + kfree(fmi_counter_data); + return 0; } -- 2.36.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#12443): https://lists.yoctoproject.org/g/linux-yocto/message/12443 Mute This Topic: https://lists.yoctoproject.org/mt/98555947/21656 Group Owner: linux-yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-