From 7a1a1fc5d931e2b853c3f28aa763fb54de93eca2 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Mon, 8 Feb 2021 23:33:29 +0100 Subject: [PATCH] st/nine: Fix leak at device destruction MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit At the release of the last object holding a reference on the device, the device dtor was executed and the objector dtor was ignored. The proper way is to execute the object dtor, then the device dtor. The previous code was likely for a workaround against something that was fixed since. Signed-off-by: Axel Davy Acked-by: Timur Kristóf Part-of: --- src/gallium/frontends/nine/iunknown.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gallium/frontends/nine/iunknown.c b/src/gallium/frontends/nine/iunknown.c index c3d4f5d..2f3286a 100644 --- a/src/gallium/frontends/nine/iunknown.c +++ b/src/gallium/frontends/nine/iunknown.c @@ -134,14 +134,13 @@ NineUnknown_Release( struct NineUnknown *This ) ULONG r = p_atomic_dec_return(&This->refs); if (r == 0) { - if (This->device) { - if (NineUnknown_Release(NineUnknown(This->device)) == 0) - return r; /* everything's gone */ - } /* Containers (here with !forward) take care of item destruction */ if (!This->container && This->bind == 0) { This->dtor(This); } + if (This->device) { + NineUnknown_Release(NineUnknown(This->device)); + } } return r; } @@ -157,16 +156,15 @@ NineUnknown_ReleaseWithDtorLock( struct NineUnknown *This ) ULONG r = p_atomic_dec_return(&This->refs); if (r == 0) { - if (This->device) { - if (NineUnknown_ReleaseWithDtorLock(NineUnknown(This->device)) == 0) - return r; /* everything's gone */ - } /* Containers (here with !forward) take care of item destruction */ if (!This->container && This->bind == 0) { NineLockGlobalMutex(); This->dtor(This); NineUnlockGlobalMutex(); } + if (This->device) { + NineUnknown_ReleaseWithDtorLock(NineUnknown(This->device)); + } } return r; } -- 2.7.4