* [PATCH] drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc()
@ 2026-01-29 9:25 Zilin Guan
2026-01-29 10:14 ` Lazar, Lijo
0 siblings, 1 reply; 3+ messages in thread
From: Zilin Guan @ 2026-01-29 9:25 UTC (permalink / raw)
To: alexander.deucher
Cc: christian.koenig, airlied, simona, mario.limonciello,
pratap.nirujogi, alex.hung, sakari.ailus, lijo.lazar, amd-gfx,
dri-devel, jianhao.xu, Zilin Guan
In amdgpu_acpi_enumerate_xcc(), if amdgpu_acpi_dev_init() returns -ENOMEM,
the function returns directly without releasing the allocated xcc_info,
resulting in a memory leak.
Fix this by ensuring that xcc_info is properly freed in the error paths.
Compile tested only. Issue found using a prototype static analysis tool
and code review.
Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
Signed-off-by: Zilin Guan <zilin@seu.edu.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 d31460a9e958..7c9d8a6d0bfd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -1135,8 +1135,10 @@ static int amdgpu_acpi_enumerate_xcc(void)
if (!dev_info)
ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
- if (ret == -ENOMEM)
+ if (ret == -ENOMEM) {
+ kfree(xcc_info);
return ret;
+ }
if (!dev_info) {
kfree(xcc_info);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc()
2026-01-29 9:25 [PATCH] drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc() Zilin Guan
@ 2026-01-29 10:14 ` Lazar, Lijo
2026-02-02 14:51 ` Alex Deucher
0 siblings, 1 reply; 3+ messages in thread
From: Lazar, Lijo @ 2026-01-29 10:14 UTC (permalink / raw)
To: Zilin Guan, alexander.deucher
Cc: christian.koenig, airlied, simona, mario.limonciello,
pratap.nirujogi, alex.hung, sakari.ailus, amd-gfx, dri-devel,
jianhao.xu
On 29-Jan-26 2:55 PM, Zilin Guan wrote:
> In amdgpu_acpi_enumerate_xcc(), if amdgpu_acpi_dev_init() returns -ENOMEM,
> the function returns directly without releasing the allocated xcc_info,
> resulting in a memory leak.
>
> Fix this by ensuring that xcc_info is properly freed in the error paths.
>
> Compile tested only. Issue found using a prototype static analysis tool
> and code review.
>
> Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
> Signed-off-by: Zilin Guan <zilin@seu.edu.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 d31460a9e958..7c9d8a6d0bfd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -1135,8 +1135,10 @@ static int amdgpu_acpi_enumerate_xcc(void)
> if (!dev_info)
> ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
>
> - if (ret == -ENOMEM)
> + if (ret == -ENOMEM) {
> + kfree(xcc_info);
> return ret;
> + }
>
> if (!dev_info) {
> kfree(xcc_info);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc()
2026-01-29 10:14 ` Lazar, Lijo
@ 2026-02-02 14:51 ` Alex Deucher
0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2026-02-02 14:51 UTC (permalink / raw)
To: Lazar, Lijo
Cc: Zilin Guan, alexander.deucher, christian.koenig, airlied, simona,
mario.limonciello, pratap.nirujogi, alex.hung, sakari.ailus,
amd-gfx, dri-devel, jianhao.xu
Applied. Thanks!
On Thu, Jan 29, 2026 at 5:15 AM Lazar, Lijo <lijo.lazar@amd.com> wrote:
>
>
>
> On 29-Jan-26 2:55 PM, Zilin Guan wrote:
> > In amdgpu_acpi_enumerate_xcc(), if amdgpu_acpi_dev_init() returns -ENOMEM,
> > the function returns directly without releasing the allocated xcc_info,
> > resulting in a memory leak.
> >
> > Fix this by ensuring that xcc_info is properly freed in the error paths.
> >
> > Compile tested only. Issue found using a prototype static analysis tool
> > and code review.
> >
> > Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
> > Signed-off-by: Zilin Guan <zilin@seu.edu.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 d31460a9e958..7c9d8a6d0bfd 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> > @@ -1135,8 +1135,10 @@ static int amdgpu_acpi_enumerate_xcc(void)
> > if (!dev_info)
> > ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
> >
> > - if (ret == -ENOMEM)
> > + if (ret == -ENOMEM) {
> > + kfree(xcc_info);
> > return ret;
> > + }
> >
> > if (!dev_info) {
> > kfree(xcc_info);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-02 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29 9:25 [PATCH] drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc() Zilin Guan
2026-01-29 10:14 ` Lazar, Lijo
2026-02-02 14:51 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox