[bug report] drm: Track drm_mm allocators and show leaks on shutdown

Dan Carpenter dan.carpenter at linaro.org
Tue May 30 11:22:49 UTC 2023


Hello Chris Wilson,

The patch 5705670d0463: "drm: Track drm_mm allocators and show leaks
on shutdown" from Oct 31, 2016, leads to the following Smatch static
checker warning:

	drivers/gpu/drm/drm_mm.c:1001 drm_mm_takedown()
	warn: sleeping in atomic context

drivers/gpu/drm/drm_mm.c
    991  * drm_mm_takedown - clean up a drm_mm allocator
    992  * @mm: drm_mm allocator to clean up
    993  *
    994  * Note that it is a bug to call this function on an allocator which is not
    995  * clean.
    996  */
    997 void drm_mm_takedown(struct drm_mm *mm)
    998 {
    999         if (WARN(!drm_mm_clean(mm),
    1000                  "Memory manager not clean during takedown.\n"))
--> 1001                 show_leaks(mm);
                         ^^^^^^^^^^^^^^^
The show_leaks() function does a GFP_KERNEL allocation but a couple
of the callers for drm_mm_takedown() are holding spinlocks so it's a
sleeping in atomic bug.

The problematic callers are ttm_range_man_fini_nocheck() and
amdgpu_gtt_mgr_fini().

    1002 }

regards,
dan carpenter


More information about the amd-gfx mailing list