From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3751046AA8C; Fri, 9 Oct 2026 14:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555965; cv=none; b=pBCtN0fqFeARhiYsDHXzUzzK84MQcJwjdEqYhsHyAbP6Bohued+CXPRVn2Q1m5AyOYQDPSF3FDYK8PK9lro4nQIh7Kutekn3EcBrTwy49cIjJyijaHzv0WjePSaDYyGcMHrKuaF6SvEgtNTyqBrudNG/ISkMG05jgPcgW1aeQPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555965; c=relaxed/simple; bh=uClWi5064l1s9/zj7wE4krE/aVtk5DZj8/LNWJ40G2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HYz+jCjPiCnkK+7lVE1klyOW3grO0erQqqBmuf6c4ff+2jPiSD3r5FrjLWUZlPs806OSoeqr+GAGIoR70zSCKN/4B++r+nW0P8NPRWvC+nstI8n5m/tZ07raTpnRSKWn79dcqxCa7mmzwuUM9OfwdKp0ZFtpFIyAXnWZRyTkVNc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KD+Ojt+h; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KD+Ojt+h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B96431F000FF; Fri, 9 Oct 2026 14:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791555963; bh=/5vyoMEmcPQMgDuW3jt/6O9pVM1o+7l1rOnco/D7OIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KD+Ojt+hDkyu3afqHwNg0LLKQslpl2Al7u+F667mFGJ2gKiVLrWzkZ4vipyHhSh1M D9iGadl13H1PxjOJo6nsz6zCU13XU2BHswhK2HkVY+ULhsSaF9Y4KfyoaTKVfsbPOo QI2ztUvvl3pwbAunmfphWvD8ws64DogrQxV70owM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , Alex Deucher Subject: [PATCH 6.18 146/403] drm/amdgpu: fix ACP MFD device leak on init failure Date: Fri, 9 Oct 2026 16:08:27 +0200 Message-ID: <20261009140955.486375917@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140952.119038291@linuxfoundation.org> References: <20261009140952.119038291@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li commit f0013046151b7467e62c471c1c83d63ea255799c upstream. acp_hw_init() registers ACP child devices with mfd_add_devices() before attaching them to the ACP power domain and initializing the hardware. If attaching a child to the power domain fails, or if the ACP reset or clock enable operation times out, the failure path frees only the source cell, resource, and platform-data allocations. The child platform devices already registered by mfd_add_devices() remain registered and are never released. Remove the children from the power domain and unregister the MFD devices on failures that occur after mfd_add_devices() succeeds. Keep mfd_add_devices() failures on the existing cleanup path since the MFD core already rolls back partially registered children itself. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fixes: 25030321ba28 ("drm/amd: add pm domain for ACP IP sub blocks") Signed-off-by: Guangshuo Li Signed-off-by: Alex Deucher (cherry picked from commit 63da68d6a2279ec945581c990c5a59a5ae8b5560) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c @@ -318,7 +318,7 @@ static int acp_hw_init(struct amdgpu_ip_ r = device_for_each_child(adev->acp.parent, &adev->acp.acp_genpd->gpd, acp_genpd_add_device); if (r) - goto failure; + goto failure_remove_mfd; break; } default: @@ -440,7 +440,7 @@ static int acp_hw_init(struct amdgpu_ip_ r = device_for_each_child(adev->acp.parent, &adev->acp.acp_genpd->gpd, acp_genpd_add_device); if (r) - goto failure; + goto failure_remove_mfd; } /* Assert Soft reset of ACP */ @@ -458,7 +458,7 @@ static int acp_hw_init(struct amdgpu_ip_ if (--count == 0) { dev_err(&adev->pdev->dev, "Failed to reset ACP\n"); r = -ETIMEDOUT; - goto failure; + goto failure_remove_mfd; } udelay(100); } @@ -476,7 +476,7 @@ static int acp_hw_init(struct amdgpu_ip_ if (--count == 0) { dev_err(&adev->pdev->dev, "Failed to reset ACP\n"); r = -ETIMEDOUT; - goto failure; + goto failure_remove_mfd; } udelay(100); } @@ -486,6 +486,11 @@ static int acp_hw_init(struct amdgpu_ip_ cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val); return 0; +failure_remove_mfd: + device_for_each_child(adev->acp.parent, NULL, + acp_genpd_remove_device); + mfd_remove_devices(adev->acp.parent); + failure: kfree(i2s_pdata); kfree(adev->acp.acp_res);