Hi Leo
On 26/01/2026 13:52, Leo Yan wrote:
The memory leak detector reports:
echo clear > /sys/kernel/debug/kmemleak modprobe coresight_funnel rmmod coresight_funnel
# Scan memory leak and report it echo scan > /sys/kernel/debug/kmemleak cat /sys/kernel/debug/kmemleak unreferenced object 0xffff0008020c7200 (size 64): comm "modprobe", pid 410, jiffies 4295333721 hex dump (first 32 bytes): d8 da fe 7e 09 00 ff ff e8 2e ff 7e 09 00 ff ff ...~.......~.... b0 6c ff 7e 09 00 ff ff 30 83 00 7f 09 00 ff ff .l.~....0....... backtrace (crc 4116a690): kmemleak_alloc+0xd8/0xf8 __kmalloc_node_track_caller_noprof+0x2c8/0x6f0 krealloc_node_align_noprof+0x13c/0x2c8 coresight_alloc_device_name+0xe4/0x158 [coresight] 0xffffd327ecef8394 0xffffd327ecef85ec amba_probe+0x118/0x1c8 really_probe+0xc8/0x3f0 __driver_probe_device+0x88/0x190 driver_probe_device+0x44/0x120 __driver_attach+0x100/0x238 bus_for_each_dev+0x84/0xf0 driver_attach+0x2c/0x40 bus_add_driver+0x128/0x258 driver_register+0x64/0x138 __amba_driver_register+0x2c/0x48
Change to use devm_krealloc_array() for allocation fwnode_list so that the device model can automatically release the memory when the module is unloaded.
Fixes: 0f5f9b6ba9e1 ("coresight: Use platform agnostic names") Signed-off-by: Leo Yan leo.yan@arm.com
drivers/hwtracing/coresight/coresight-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index c660cf8adb1c7cafff8f85e501f056e4e151e372..ed304f292b7b02e89c59053d43f88fbf663cc993 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1546,7 +1546,7 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict, if (idx < 0) { /* Make space for the new entry */ idx = dict->nr_idx;
list = krealloc_array(dict->fwnode_list,
list = devm_krealloc_array(dev, dict->fwnode_list, idx + 1, sizeof(*dict->fwnode_list),
This is wrong. This would mean, the array gets released when the "dev" goes away and thats not good. This is a per-driver list, not a per-device list. Also, please remember that, we need to keep that node alive when the device goes away, to make sure to allocate the same device name when if/it comes back. May be, you could release the list and array, when the "driver" goes away.
Kind regards Suzuki
GFP_KERNEL); if (ZERO_OR_NULL_PTR(list)) {