summaryrefslogtreecommitdiff
path: root/hal
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2019-12-06 20:28:43 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2019-12-06 20:28:43 +0000
commitb60e5ffa03063f5ea8d2717e91ac675fc0fc0463 (patch)
treeeaa3103cea79aeb1b0aaa53e65e7c33fd50fd2bb /hal
parent6f561e7e412ba4b1dc4ca9d3500b38ca38b6c87f (diff)
parent506fd42a89494c836eda69df354177affa0820f8 (diff)
downloadaudio-b60e5ffa03063f5ea8d2717e91ac675fc0fc0463.tar.gz
audio: free and assign NULL to global static device pointer am: 506fd42a89
Change-Id: Ie5298d1d83de872c5a2eb64c35ca2a8fcfac0c75
Diffstat (limited to 'hal')
-rw-r--r--hal/audio_hw.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index cba2e10..1e3bb91 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -6284,12 +6284,10 @@ static int adev_verify_devices(struct audio_device *adev)
static int adev_close(hw_device_t *device)
{
size_t i;
- struct audio_device *adev_temp = (struct audio_device *)device;
-
- if (!adev_temp)
- return 0;
pthread_mutex_lock(&adev_init_lock);
+ if (!device || ((struct audio_device *)device != adev))
+ goto done;
if ((--audio_device_ref_count) == 0) {
audio_extn_snd_mon_unregister_listener(adev);
@@ -6308,10 +6306,11 @@ static int adev_close(hw_device_t *device)
adev->adm_deinit(adev->adm_data);
pthread_mutex_destroy(&adev->lock);
free(device);
+ adev = NULL;
}
+done:
pthread_mutex_unlock(&adev_init_lock);
-
return 0;
}