* [PATCH] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc()
@ 2026-09-16 9:54 Wentao Liang
2026-09-16 11:18 ` Lazar, Lijo
2026-09-16 14:28 ` Deucher, Alexander
0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-09-16 9:54 UTC (permalink / raw)
To: airlied
Cc: alexander.deucher, amd-gfx, christian.koenig, dri-devel,
lijo.lazar, linux-kernel, simona, Wentao Liang, stable
amdgpu_acpi_enumerate_xcc() looks up each XCC ACPI device with
acpi_dev_get_first_match_dev(), which takes a reference to the device.
The reference is dropped with acpi_dev_put() after the XCC info is
initialized, but if the kzalloc_obj() allocation of the XCC info fails
the function returns -ENOMEM without releasing the reference, leaking
the last reference to the ACPI device.
Drop the ACPI device reference on the allocation failure path before
returning.
Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 516ab9cf88fc..8d3f1f5a141e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -1167,8 +1167,10 @@ int amdgpu_acpi_enumerate_xcc(void)
}
xcc_info = kzalloc_obj(struct amdgpu_acpi_xcc_info);
- if (!xcc_info)
+ if (!xcc_info) {
+ acpi_dev_put(acpi_dev);
return -ENOMEM;
+ }
INIT_LIST_HEAD(&xcc_info->list);
xcc_info->handle = acpi_device_handle(acpi_dev);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc()
2026-09-16 9:54 [PATCH] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc() Wentao Liang
@ 2026-09-16 11:18 ` Lazar, Lijo
2026-09-16 14:28 ` Deucher, Alexander
1 sibling, 0 replies; 3+ messages in thread
From: Lazar, Lijo @ 2026-09-16 11:18 UTC (permalink / raw)
To: Wentao Liang, airlied
Cc: alexander.deucher, amd-gfx, christian.koenig, dri-devel,
linux-kernel, simona, stable
On 16-Sep-26 3:24 PM, Wentao Liang wrote:
> amdgpu_acpi_enumerate_xcc() looks up each XCC ACPI device with
> acpi_dev_get_first_match_dev(), which takes a reference to the device.
> The reference is dropped with acpi_dev_put() after the XCC info is
> initialized, but if the kzalloc_obj() allocation of the XCC info fails
> the function returns -ENOMEM without releasing the reference, leaking
> the last reference to the ACPI device.
>
> Drop the ACPI device reference on the allocation failure path before
> returning.
>
> Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Thanks,
Lijo
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 516ab9cf88fc..8d3f1f5a141e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -1167,8 +1167,10 @@ int amdgpu_acpi_enumerate_xcc(void)
> }
>
> xcc_info = kzalloc_obj(struct amdgpu_acpi_xcc_info);
> - if (!xcc_info)
> + if (!xcc_info) {
> + acpi_dev_put(acpi_dev);
> return -ENOMEM;
> + }
>
> INIT_LIST_HEAD(&xcc_info->list);
> xcc_info->handle = acpi_device_handle(acpi_dev);
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc()
2026-09-16 9:54 [PATCH] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc() Wentao Liang
2026-09-16 11:18 ` Lazar, Lijo
@ 2026-09-16 14:28 ` Deucher, Alexander
1 sibling, 0 replies; 3+ messages in thread
From: Deucher, Alexander @ 2026-09-16 14:28 UTC (permalink / raw)
To: Wentao Liang, airlied
Cc: amd-gfx, Koenig, Christian, dri-devel, Lazar, Lijo, linux-kernel,
simona, stable
Public
Applied. Thanks!
> -----Original Message-----
> From: Wentao Liang <vulab@iscas.ac.cn>
> Sent: Wednesday, September 16, 2026 5:55 AM
> To: airlied@gmail.com
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; amd-
> gfx@lists.freedesktop.org; Koenig, Christian <Christian.Koenig@amd.com>;
> dri-devel@lists.freedesktop.org; Lazar, Lijo <Lijo.Lazar@amd.com>; linux-
> kernel@vger.kernel.org; simona@ffwll.ch; Wentao Liang <vulab@iscas.ac.cn>;
> stable@vger.kernel.org
> Subject: [PATCH] drm/amdgpu: Fix acpi device leak in
> amdgpu_acpi_enumerate_xcc()
>
> amdgpu_acpi_enumerate_xcc() looks up each XCC ACPI device with
> acpi_dev_get_first_match_dev(), which takes a reference to the device.
> The reference is dropped with acpi_dev_put() after the XCC info is initialized,
> but if the kzalloc_obj() allocation of the XCC info fails the function returns -
> ENOMEM without releasing the reference, leaking the last reference to the
> ACPI device.
>
> Drop the ACPI device reference on the allocation failure path before returning.
>
> Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 516ab9cf88fc..8d3f1f5a141e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -1167,8 +1167,10 @@ int amdgpu_acpi_enumerate_xcc(void)
> }
>
> xcc_info = kzalloc_obj(struct amdgpu_acpi_xcc_info);
> - if (!xcc_info)
> + if (!xcc_info) {
> + acpi_dev_put(acpi_dev);
> return -ENOMEM;
> + }
>
> INIT_LIST_HEAD(&xcc_info->list);
> xcc_info->handle = acpi_device_handle(acpi_dev);
> --
> 2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-16 14:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 9:54 [PATCH] drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc() Wentao Liang
2026-09-16 11:18 ` Lazar, Lijo
2026-09-16 14:28 ` Deucher, Alexander
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®