* [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown
@ 2026-11-16 3:27 Mirian Shilakadze
2026-11-16 3:32 ` no-reply
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mirian Shilakadze @ 2026-11-16 3:27 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: Michał Grzelak <michal.grzelak@intel.com>
During initialization of DRM buddy memory manager at drm_buddy_init,
mm->free_trees array is allocated for both clear and dirty RB trees.
During cleanup happening at drm_buddy_fini it is never freed, leading to
following memory leaks observed on xe module load & unload cycles:
kmemleak_alloc+0x4a/0x90
__kmalloc_cache_noprof+0x488/0x800
drm_buddy_init+0xc2/0x330 [drm_buddy]
__xe_ttm_vram_mgr_init+0xc3/0x190 [xe]
xe_ttm_stolen_mgr_init+0xf5/0x9d0 [xe]
xe_device_probe+0x326/0x9e0 [xe]
xe_pci_probe+0x39a/0x610 [xe]
local_pci_probe+0x47/0xb0
pci_device_probe+0xf3/0x260
really_probe+0xf1/0x3c0
__driver_probe_device+0x8c/0x180
driver_probe_device+0x24/0xd0
__driver_attach+0x10f/0x220
bus_for_each_dev+0x7f/0xe0
driver_attach+0x1e/0x30
bus_add_driver+0x151/0x290
Deallocate array for free trees when cleaning up buddy memory manager
in the same way as if going through out_free_tree label.
Fixes: d4cd665c98c1 ("drm/buddy: Separate clear and dirty free block trees")
Signed-off-by: Michał Grzelak <michal.grzelak@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Link: https://patch.msgid.link/20251208102714.4008260-2-michal.grzelak@intel.com
(cherry picked from commit 7d0507772406e129329983b8b807e5b499bd74fd)
https://virtuozzo.atlassian.net/browse/VSTOR-154850
Feature: fix ms/drm
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
Item 2 from the review of VSTOR-153702. The change is the same as
upstream.
Not run. Build-tested only, drm_buddy.o compiles with the
211.52.1.22.22 config.
drivers/gpu/drm/drm_buddy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index f2c92902e4a3..3f1a9892f2a3 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -419,6 +419,7 @@ void drm_buddy_fini(struct drm_buddy *mm)
for_each_free_tree(i)
kfree(mm->free_trees[i]);
+ kfree(mm->free_trees);
kfree(mm->roots);
}
EXPORT_SYMBOL(drm_buddy_fini);
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown
2026-11-16 3:27 [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown Mirian Shilakadze
@ 2026-11-16 3:32 ` no-reply
2026-11-16 15:59 ` Konstantin Khorenko
2026-11-16 15:59 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2026-11-16 3:32 UTC (permalink / raw)
To: Mirian Shilakadze, khorenko; +Cc: devel
> From: Michał Grzelak <michal.grzelak@intel.com>
>
> During initialization of DRM buddy memory manager at drm_buddy_init,
> mm->free_trees array is allocated for both clear and dirty RB trees.
> During cleanup happening at drm_buddy_fini it is never freed, leading to
> following memory leaks observed on xe module load & unload cycles:
>
> kmemleak_alloc+0x4a/0x90
> __kmalloc_cache_noprof+0x488/0x800
> drm_buddy_init+0xc2/0x330 [drm_buddy]
> __xe_ttm_vram_mgr_init+0xc3/0x190 [xe]
> xe_ttm_stolen_mgr_init+0xf5/0x9d0 [xe]
> xe_device_probe+0x326/0x9e0 [xe]
> xe_pci_probe+0x39a/0x610 [xe]
> local_pci_probe+0x47/0xb0
> [ ... ]
>
> https://virtuozzo.atlassian.net/browse/VSTOR-154850
> Feature: fix ms/drm
>
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261116032734.24795-1-mirian.shilakadze@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown
2026-11-16 3:27 [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown Mirian Shilakadze
2026-11-16 3:32 ` no-reply
@ 2026-11-16 15:59 ` Konstantin Khorenko
2026-11-16 15:59 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 15:59 UTC (permalink / raw)
To: Mirian Shilakadze; +Cc: devel
Applying as is.
On Mon, 16 Nov 2026 07:27:21 +0400, Mirian Shilakadze <mirian.shilakadze@virtuozzo.com> wrote:
> Deallocate array for free trees when cleaning up buddy memory manager
> in the same way as if going through out_free_tree label.
Same hunk as mainline 7d0507772406e. RHEL 264.7.1 already carries it,
so this commit drops out at the rebase onto 264.x.
Separate patches, not needed for this one. I created a task for it:
1. drm_buddy.c here lacks three later mainline fixes: 5488a29596cdb
("drm/buddy: Prevent BUG_ON by validating rounded allocation"),
56bc6384314fb ("gpu/buddy: bail out of try_harder when alignment
cannot be honoured") and 0251963afd22d ("gpu/buddy: Fix
use-after-free in split_block() call sites"). The first is a
BUG_ON on a contiguous allocation rounded past mm->size, the last a
use-after-free on the split_block() error paths, which 264.x still
has too.
https://virtuozzo.atlassian.net/browse/VSTOR-155318
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown
2026-11-16 3:27 [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown Mirian Shilakadze
2026-11-16 3:32 ` no-reply
2026-11-16 15:59 ` Konstantin Khorenko
@ 2026-11-16 15:59 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 15:59 UTC (permalink / raw)
To: Mirian Shilakadze; +Cc: devel
On Mon, 16 Nov 2026 07:27:21 +0400, Mirian Shilakadze wrote:
> ms/drm/buddy: release free_trees array on buddy mm teardown
Applied to branch-rh10-6.12.0-211.75.1.24.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.2.vz10, thanks!
[1/1] ms/drm/buddy: release free_trees array on buddy mm teardown
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/9bcedb3e4446
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-16 16:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 3:27 [Devel] [PATCH hci-8.1] ms/drm/buddy: release free_trees array on buddy mm teardown Mirian Shilakadze
2026-11-16 3:32 ` no-reply
2026-11-16 15:59 ` Konstantin Khorenko
2026-11-16 15:59 ` Konstantin Khorenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.