From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CA25D78770 for ; Fri, 19 Dec 2025 19:33:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 596EA10F093; Fri, 19 Dec 2025 19:33:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="PjLonlyH"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id E690810EF33; Fri, 19 Dec 2025 19:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1766172779; x=1797708779; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=DkySkSjU1SBFo79I0lrvRHAyMklZpIocPvhHQylXSRQ=; b=PjLonlyH0/lgbds1IAMnAnUWjylQWJJPq/tM2Q0jZ16gXAH643wL3zBA U45Q4vaXO0Txof8iXxOgK0PCMVGp5pSwfJDsD/Po58dDmX3/8wr5EIKBM IopOvMXwvA6po7UZn0iJ9idIv+15ZQhJ87RLIL5l7h5TZfqGgohKFo7ys wdOs2ZuQkhn+LTEqLZNG5lcoGvgB7wtGqs4BYeKMmio+pja3qHlAXb/FG nHvUjmp2AN0fJcXXE8J1W5mhEnMDYLii1+SKdXTl7zSFDS3wm9YL3uOkv 4H1xZazi515gCUG5lDymfHq1vwNJE9yzBVitNfOBadojbqonl0BiPyC3R w==; X-CSE-ConnectionGUID: g5SxUEMPTMmsk0R+3TZnqw== X-CSE-MsgGUID: w7tR2rmGT1OMYsa/Wx8v2A== X-IronPort-AV: E=McAfee;i="6800,10657,11647"; a="90796698" X-IronPort-AV: E=Sophos;i="6.21,162,1763452800"; d="scan'208";a="90796698" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2025 11:32:58 -0800 X-CSE-ConnectionGUID: aXFJzeHGQHyOBRUWm1a2GQ== X-CSE-MsgGUID: VJHcK9EwSbmX0SnQoRfW5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,162,1763452800"; d="scan'208";a="229967599" Received: from administrator-system-product-name.igk.intel.com ([10.91.214.181]) by fmviesa001.fm.intel.com with ESMTP; 19 Dec 2025 11:32:56 -0800 From: =?UTF-8?q?Micha=C5=82=20Grzelak?= To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: matthew.brost@intel.com, thomas.hellstrom@linux.intel.com, rodrigo.vivi@intel.com, =?UTF-8?q?Micha=C5=82=20Grzelak?= , Lucas De Marchi , Matthew Auld Subject: [RESEND 1/1] drm/buddy: release free_trees array on buddy mm teardown Date: Fri, 19 Dec 2025 20:32:37 +0100 Message-ID: <20251219193237.1454565-1-michal.grzelak@intel.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" 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 Reviewed-by: Lucas De Marchi Reviewed-by: Matthew Auld --- 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 2f279b46bd2c..8308116058cc 100644 --- a/drivers/gpu/drm/drm_buddy.c +++ b/drivers/gpu/drm/drm_buddy.c @@ -420,6 +420,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.45.2