* [PATCH v1] drm/radeon: fix memory leak in radeon_ring_restore() on lock failure
@ 2026-04-16 19:55 Yuho Choi
2026-04-17 14:05 ` Alex Deucher
0 siblings, 1 reply; 3+ messages in thread
From: Yuho Choi @ 2026-04-16 19:55 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter
Cc: amd-gfx, dri-devel, linux-kernel, Yuho Choi
radeon_ring_restore() takes ownership of the data buffer allocated by
radeon_ring_backup(). The caller (radeon_gpu_reset()) only frees it in
the non-restore branch; in the restore branch it relies on
radeon_ring_restore() to free it.
If radeon_ring_lock() fails, the function returned early without calling
kvfree(data), leaking the ring backup buffer on every GPU reset that
fails at the lock stage. During repeated GPU resets this causes
cumulative kernel memory exhaustion.
Free data before returning the error.
Fixes: 55d7c22192be ("drm/radeon: implement ring saving on reset v4")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
drivers/gpu/drm/radeon/radeon_ring.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 581ae20c46e4b..a5dff072c1ac0 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -356,8 +356,10 @@ int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
/* restore the saved ring content */
r = radeon_ring_lock(rdev, ring, size);
- if (r)
+ if (r) {
+ kvfree(data);
return r;
+ }
for (i = 0; i < size; ++i) {
radeon_ring_write(ring, data[i]);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] drm/radeon: fix memory leak in radeon_ring_restore() on lock failure
2026-04-16 19:55 [PATCH v1] drm/radeon: fix memory leak in radeon_ring_restore() on lock failure Yuho Choi
@ 2026-04-17 14:05 ` Alex Deucher
2026-04-17 14:50 ` 최유호
0 siblings, 1 reply; 3+ messages in thread
From: Alex Deucher @ 2026-04-17 14:05 UTC (permalink / raw)
To: Yuho Choi
Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
amd-gfx, dri-devel, linux-kernel
Applied. Thanks!
On Fri, Apr 17, 2026 at 3:06 AM Yuho Choi <dbgh9129@gmail.com> wrote:
>
> radeon_ring_restore() takes ownership of the data buffer allocated by
> radeon_ring_backup(). The caller (radeon_gpu_reset()) only frees it in
> the non-restore branch; in the restore branch it relies on
> radeon_ring_restore() to free it.
>
> If radeon_ring_lock() fails, the function returned early without calling
> kvfree(data), leaking the ring backup buffer on every GPU reset that
> fails at the lock stage. During repeated GPU resets this causes
> cumulative kernel memory exhaustion.
>
> Free data before returning the error.
>
> Fixes: 55d7c22192be ("drm/radeon: implement ring saving on reset v4")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
> drivers/gpu/drm/radeon/radeon_ring.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
> index 581ae20c46e4b..a5dff072c1ac0 100644
> --- a/drivers/gpu/drm/radeon/radeon_ring.c
> +++ b/drivers/gpu/drm/radeon/radeon_ring.c
> @@ -356,8 +356,10 @@ int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
>
> /* restore the saved ring content */
> r = radeon_ring_lock(rdev, ring, size);
> - if (r)
> + if (r) {
> + kvfree(data);
> return r;
> + }
>
> for (i = 0; i < size; ++i) {
> radeon_ring_write(ring, data[i]);
> --
> 2.50.1 (Apple Git-155)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] drm/radeon: fix memory leak in radeon_ring_restore() on lock failure
2026-04-17 14:05 ` Alex Deucher
@ 2026-04-17 14:50 ` 최유호
0 siblings, 0 replies; 3+ messages in thread
From: 최유호 @ 2026-04-17 14:50 UTC (permalink / raw)
To: Alex Deucher
Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
amd-gfx, dri-devel, linux-kernel, Kim, Taegyu
Dear Alex,
Thank you for applying the patch.
Best regards,
Yuho Choi
On Fri, 17 Apr 2026 at 10:05, Alex Deucher <alexdeucher@gmail.com> wrote:
>
> Applied. Thanks!
>
> On Fri, Apr 17, 2026 at 3:06 AM Yuho Choi <dbgh9129@gmail.com> wrote:
> >
> > radeon_ring_restore() takes ownership of the data buffer allocated by
> > radeon_ring_backup(). The caller (radeon_gpu_reset()) only frees it in
> > the non-restore branch; in the restore branch it relies on
> > radeon_ring_restore() to free it.
> >
> > If radeon_ring_lock() fails, the function returned early without calling
> > kvfree(data), leaking the ring backup buffer on every GPU reset that
> > fails at the lock stage. During repeated GPU resets this causes
> > cumulative kernel memory exhaustion.
> >
> > Free data before returning the error.
> >
> > Fixes: 55d7c22192be ("drm/radeon: implement ring saving on reset v4")
> > Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> > ---
> > drivers/gpu/drm/radeon/radeon_ring.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
> > index 581ae20c46e4b..a5dff072c1ac0 100644
> > --- a/drivers/gpu/drm/radeon/radeon_ring.c
> > +++ b/drivers/gpu/drm/radeon/radeon_ring.c
> > @@ -356,8 +356,10 @@ int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
> >
> > /* restore the saved ring content */
> > r = radeon_ring_lock(rdev, ring, size);
> > - if (r)
> > + if (r) {
> > + kvfree(data);
> > return r;
> > + }
> >
> > for (i = 0; i < size; ++i) {
> > radeon_ring_write(ring, data[i]);
> > --
> > 2.50.1 (Apple Git-155)
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-17 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 19:55 [PATCH v1] drm/radeon: fix memory leak in radeon_ring_restore() on lock failure Yuho Choi
2026-04-17 14:05 ` Alex Deucher
2026-04-17 14:50 ` 최유호
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox