]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/buddy: release free_trees array on buddy mm teardown
authorMichał Grzelak <michal.grzelak@intel.com>
Mon, 8 Dec 2025 10:27:14 +0000 (11:27 +0100)
committerArunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Tue, 20 Jan 2026 05:16:41 +0000 (10:46 +0530)
commit7d0507772406e129329983b8b807e5b499bd74fd
tree3eb1ccf809e259daa18194ecfb7983a3e6b6ba5d
parentab4c3dcf9a71582503b4fb25aeab884c696cab25
drm/buddy: release free_trees array on buddy mm teardown

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
drivers/gpu/drm/drm_buddy.c