From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3ACB2F39C2; Wed, 21 Jan 2026 18:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769019871; cv=none; b=lnsiXgLU5lQk12ePff+ORg7KCbrLXtIMtkE0w14jqJbbNMb9ymj6pyzCx4GfQ0/b1YdBSCCPHzli8e2CHLouYAVh4U1gwYG0HOZTB7ww7KEsn69f7AQ34svDtsfy5VWIiD5l2OZMCwuL3K/lhk7sRe75vqaiN9kyzg3zWcWLG5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769019871; c=relaxed/simple; bh=3eE3I9lDSP2yOyiTEI5GIMza6zw2wuYy5wf02AaNdv4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F2Z2g5WnFt2M8GFVqsTb8YSbKrNchVzzlgmUte7mrcPWbwnNzeOTaz5LeOhtjfBJB0gCHye1cbz/PBGLES7afEPu5ZjG4wNv+Uf8O/UCIUSxzJXFj4GUG006KOJFR37GQio91zRuOw6xu0mvjqlkX4xBq0rttTPHcfrSO/G9iyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TxxixT4P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TxxixT4P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA0CC4CEF1; Wed, 21 Jan 2026 18:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769019871; bh=3eE3I9lDSP2yOyiTEI5GIMza6zw2wuYy5wf02AaNdv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxxixT4PgOwrTb5aH3TDFNLz0Vlvh4vV5lyE+CtVk2ND0RpDb0jI4WgHvK9zpLjOO 9BmAXe4uddpZXVVhEaaLiBFDqtSlUIR/fCINL/Jg3kbyyvgpPFUfzAgz8df5Xq/ipA SFk/iu8zh+hyITlYITF+3kQPTyvCKk+I75yke3Bc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haoxiang Li , Felix Kuehling , Oak Zeng , Alex Deucher Subject: [PATCH 6.12 100/139] drm/amdkfd: fix a memory leak in device_queue_manager_init() Date: Wed, 21 Jan 2026 19:15:48 +0100 Message-ID: <20260121181415.050332212@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121181411.452263583@linuxfoundation.org> References: <20260121181411.452263583@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haoxiang Li commit 80614c509810fc051312d1a7ccac8d0012d6b8d0 upstream. If dqm->ops.initialize() fails, add deallocate_hiq_sdma_mqd() to release the memory allocated by allocate_hiq_sdma_mqd(). Move deallocate_hiq_sdma_mqd() up to ensure proper function visibility at the point of use. Fixes: 11614c36bc8f ("drm/amdkfd: Allocate MQD trunk for HIQ and SDMA") Signed-off-by: Haoxiang Li Signed-off-by: Felix Kuehling Reviewed-by: Oak Zeng Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher (cherry picked from commit b7cccc8286bb9919a0952c812872da1dcfe9d390) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 19 ++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -2756,6 +2756,14 @@ static int allocate_hiq_sdma_mqd(struct return retval; } +static void deallocate_hiq_sdma_mqd(struct kfd_node *dev, + struct kfd_mem_obj *mqd) +{ + WARN(!mqd, "No hiq sdma mqd trunk to free"); + + amdgpu_amdkfd_free_gtt_mem(dev->adev, &mqd->gtt_mem); +} + struct device_queue_manager *device_queue_manager_init(struct kfd_node *dev) { struct device_queue_manager *dqm; @@ -2879,19 +2887,14 @@ struct device_queue_manager *device_queu return dqm; } + if (!dev->kfd->shared_resources.enable_mes) + deallocate_hiq_sdma_mqd(dev, &dqm->hiq_sdma_mqd); + out_free: kfree(dqm); return NULL; } -static void deallocate_hiq_sdma_mqd(struct kfd_node *dev, - struct kfd_mem_obj *mqd) -{ - WARN(!mqd, "No hiq sdma mqd trunk to free"); - - amdgpu_amdkfd_free_gtt_mem(dev->adev, &mqd->gtt_mem); -} - void device_queue_manager_uninit(struct device_queue_manager *dqm) { dqm->ops.stop(dqm);