kernel_samsung_a53x/drivers/hwtracing/coresight
Suzuki K Poulose e8f4164664 coresight: tmc: sg: Do not leak sg_table
[ Upstream commit c58dc5a1f886f2fcc1133746d0cbaa1fe7fd44ff ]

Running perf with cs_etm on Juno triggers the following kmemleak warning !

:~# cat /sys/kernel/debug/kmemleak
 unreferenced object 0xffffff8806b6d720 (size 96):
 comm "perf", pid 562, jiffies 4297810960
 hex dump (first 32 bytes):
 38 d8 13 07 88 ff ff ff 00 d0 9e 85 c0 ff ff ff  8...............
 00 10 00 88 c0 ff ff ff 00 f0 ff f7 ff 00 00 00  ................
 backtrace (crc 1dbf6e00):
 [<ffffffc08107381c>] kmemleak_alloc+0xbc/0xd8
 [<ffffffc0802f9798>] kmalloc_trace_noprof+0x220/0x2e8
 [<ffffffc07bb71948>] tmc_alloc_sg_table+0x48/0x208 [coresight_tmc]
 [<ffffffc07bb71cbc>] tmc_etr_alloc_sg_buf+0xac/0x240 [coresight_tmc]
 [<ffffffc07bb72538>] tmc_alloc_etr_buf.constprop.0+0x1f0/0x260 [coresight_tmc]
 [<ffffffc07bb7280c>] alloc_etr_buf.constprop.0.isra.0+0x74/0xa8 [coresight_tmc]
 [<ffffffc07bb72950>] tmc_alloc_etr_buffer+0x110/0x260 [coresight_tmc]
 [<ffffffc07bb38afc>] etm_setup_aux+0x204/0x3b0 [coresight]
 [<ffffffc08025837c>] rb_alloc_aux+0x20c/0x318
 [<ffffffc08024dd84>] perf_mmap+0x2e4/0x7a0
 [<ffffffc0802cceb0>] mmap_region+0x3b0/0xa08
 [<ffffffc0802cd8a8>] do_mmap+0x3a0/0x500
 [<ffffffc080295328>] vm_mmap_pgoff+0x100/0x1d0
 [<ffffffc0802cadf8>] ksys_mmap_pgoff+0xb8/0x110
 [<ffffffc080020688>] __arm64_sys_mmap+0x38/0x58
 [<ffffffc080028fc0>] invoke_syscall.constprop.0+0x58/0x100

This due to the fact that we do not free the "sg_table" itself while
freeing up  the SG table and data pages. Fix this by freeing the sg_table
in tmc_free_sg_table().

Fixes: 99443ea19e8b ("coresight: Add generic TMC sg table framework")
Cc: Mike Leach <mike.leach@linaro.org>
Cc: James Clark <james.clark@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Link: https://lore.kernel.org/r/20240702132846.1677261-1-suzuki.poulose@arm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:21:28 +01:00
..
coresight-catu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-catu.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-cpu-debug.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-cti-core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-cti-platform.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-cti-sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-cti.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etb10.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm-cp14.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm-perf.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm-perf.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm3x-core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm3x-sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm4x-core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm4x-sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-etm4x.h coresight: etm4x: Fix width of CCITMIN field 2024-11-18 12:12:19 +01:00
coresight-funnel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-platform.c coresight: Fix ref leak when of_coresight_parse_endpoint() fails 2024-11-23 23:20:10 +01:00
coresight-priv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-replicator.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-self-hosted-trace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-stm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-tmc-core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-tmc-etf.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-tmc-etr.c coresight: tmc: sg: Do not leak sg_table 2024-11-23 23:21:28 +01:00
coresight-tmc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-tpiu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-trbe.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
coresight-trbe.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00