Huw Davies : wineoss: Don't acquire the sessions lock after the client lock.

Alexandre Julliard julliard at winehq.org
Fri Dec 3 15:18:59 CST 2021


Module: wine
Branch: master
Commit: 7b426971245bea1c8884bca7c34f53ba8cf9c0e4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7b426971245bea1c8884bca7c34f53ba8cf9c0e4

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Dec  2 12:02:39 2021 +0000

wineoss: Don't acquire the sessions lock after the client lock.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wineoss.drv/mmdevdrv.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
index 19a59cd9ba1..b340db00c3c 100644
--- a/dlls/wineoss.drv/mmdevdrv.c
+++ b/dlls/wineoss.drv/mmdevdrv.c
@@ -1085,22 +1085,26 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
         }
     }
 
+    EnterCriticalSection(&g_sessions_lock);
     EnterCriticalSection(&This->lock);
 
     if(This->initted){
         LeaveCriticalSection(&This->lock);
+        LeaveCriticalSection(&g_sessions_lock);
         return AUDCLNT_E_ALREADY_INITIALIZED;
     }
 
     hr = setup_oss_device(mode, This->fd, fmt, NULL);
     if(FAILED(hr)){
         LeaveCriticalSection(&This->lock);
+        LeaveCriticalSection(&g_sessions_lock);
         return hr;
     }
 
     This->fmt = clone_format(fmt);
     if(!This->fmt){
         LeaveCriticalSection(&This->lock);
+        LeaveCriticalSection(&g_sessions_lock);
         return E_OUTOFMEMORY;
     }
 
@@ -1116,6 +1120,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
         CoTaskMemFree(This->fmt);
         This->fmt = NULL;
         LeaveCriticalSection(&This->lock);
+        LeaveCriticalSection(&g_sessions_lock);
         return E_OUTOFMEMORY;
     }
 
@@ -1124,6 +1129,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
         CoTaskMemFree(This->fmt);
         This->fmt = NULL;
         LeaveCriticalSection(&This->lock);
+        LeaveCriticalSection(&g_sessions_lock);
         return E_OUTOFMEMORY;
     }
 
@@ -1134,27 +1140,24 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
     This->flags = flags;
     This->oss_bufsize_bytes = 0;
 
-    EnterCriticalSection(&g_sessions_lock);
-
     hr = get_audio_session(sessionguid, This->parent, fmt->nChannels,
             &This->session);
     if(FAILED(hr)){
-        LeaveCriticalSection(&g_sessions_lock);
         HeapFree(GetProcessHeap(), 0, This->vols);
         This->vols = NULL;
         CoTaskMemFree(This->fmt);
         This->fmt = NULL;
         LeaveCriticalSection(&This->lock);
+        LeaveCriticalSection(&g_sessions_lock);
         return hr;
     }
 
     list_add_tail(&This->session->clients, &This->entry);
 
-    LeaveCriticalSection(&g_sessions_lock);
-
     This->initted = TRUE;
 
     LeaveCriticalSection(&This->lock);
+    LeaveCriticalSection(&g_sessions_lock);
 
     return S_OK;
 }




More information about the wine-cvs mailing list