Re: [PATCH mpam mpam/snapshot+extras/v6.18-rc1 v2 3/3] fs/resctrl: Migrate IOMMU groups when removing resource groups
From: Zeng Heng
Date: Thu Jul 16 2026 - 02:42:06 EST
Hi Lee,
On 2026/7/16 5:35, Lee Trager wrote:
Hi Zeng,
Thanks for the series, I found it while backporting MPAM support to 6.18.
You are welcome. Glad it could help you fix the issues you encountered.
iommu_group_get_from_kobj() returns holding a reference on group->devices_kobj, the one iommu_group_put() releases. The kobject_get() above only compensates for the kobject_put(&group->kobj) done internally by iommu_group_get_from_kobj(). Nothing in this loop ever calls iommu_group_put(), so this leaks one iommu_group reference per group in the kset on every call, e.g on rmdir and every unmount. Since device_kobj pins the group's koject, the leaked groups can never be freed.
The same pattern exists in show_rdt_iommu() from "fs/resctrl: Add support for assigning iommu_groups to resctrl groups", where it leaks one reference per group on every read of a tasks file.
There is a second, smaller leak on these break paths: kset_get_next_obj() only drops its reference on the current kobject when it is passed back as @prev on the next iteration, so breaking out of the loop also leaks the group_kobj reference taken by the iterator. I am carrying the fix below:
if (!from || iommu_matches_rdtgroup(group, from)) {
err = kstrtoint(group_kobj->name, 0, &iommu_group_id);
if (!err)
err = rdtgroup_move_iommu(iommu_group_id, to);
}
iommu_group_put(group);
if (err) {
kobject_put(group_kobj);
break;
}
Thanks,
Thank you for the review. The changes look reasonable to me, and I'll
carry these memory leak fixes into v3.
Best regards,
Zeng Heng