[PATCH v2 1/8] coresight: Fix memory leak in coresight_alloc_device_name()
Leo Yan
leo.yan at arm.com
Mon Jan 26 08:18:39 PST 2026
Hi Suzuki,
On Mon, Jan 26, 2026 at 03:48:28PM +0000, Suzuki K Poulose wrote:
[...]
> > @@ -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.
Indeed. In next spin, I will to fix the leak in module exit.
Thanks for pointing this out.
Leo
More information about the linux-arm-kernel
mailing list