summaryrefslogtreecommitdiffstats
path: root/fingerprint
diff options
context:
space:
mode:
authorTao Wu <lepton@google.com>2016-07-21 18:59:57 -0700
committerTao Wu <lepton@google.com>2016-07-21 21:46:21 -0700
commit80d7906f421a40f03e0d8151d8e182e1ad26f0d6 (patch)
tree7c76fca7a0bc44e047c974bfbdf4339880e00f84 /fingerprint
parent45626366785a528c07377b17320f9e5854f84726 (diff)
downloaddevice_generic_goldfish-80d7906f421a40f03e0d8151d8e182e1ad26f0d6.tar.gz
device_generic_goldfish-80d7906f421a40f03e0d8151d8e182e1ad26f0d6.tar.bz2
device_generic_goldfish-80d7906f421a40f03e0d8151d8e182e1ad26f0d6.zip
Fix possible lock issue in fingerprint.c
We shouldn't hold lock when calling external api since those api could be block or chain to call other callbacks we provides. Currently qemud_pipe_open is non-blocking and it shouldn't have issue. But we don't know if its behavior will change in the furture. Call notify while holding lock is a real issue. Any way, fix both of them. Change-Id: I83e9432bfe40f969f737340cd23e6b559ee2f423 Signed-off-by: Tao Wu <lepton@google.com>
Diffstat (limited to 'fingerprint')
-rw-r--r--fingerprint/fingerprint.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fingerprint/fingerprint.c b/fingerprint/fingerprint.c
index 278b4315..fbe5d0f8 100644
--- a/fingerprint/fingerprint.c
+++ b/fingerprint/fingerprint.c
@@ -477,11 +477,11 @@ static int fingerprint_remove(struct fingerprint_device *device,
}
} // end for (idx < MAX_NUM_FINGERS)
} while (!listIsEmpty);
+ qdev->listener.state = STATE_IDLE;
+ pthread_mutex_unlock(&qdev->lock);
msg.type = FINGERPRINT_TEMPLATE_REMOVED;
msg.data.removed.finger.fid = 0;
device->notify(&msg);
- qdev->listener.state = STATE_IDLE;
- pthread_mutex_unlock(&qdev->lock);
} else {
// Delete one fingerprint
// Look for this finger ID in our table.
@@ -661,8 +661,9 @@ static void* listenerFunction(void* data) {
ALOGD("----------------> %s ----------------->", __FUNCTION__);
qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)data;
+ int fd = qemu_pipe_open(FINGERPRINT_LISTEN_SERVICE_NAME);
pthread_mutex_lock(&qdev->lock);
- qdev->qchanfd = qemu_pipe_open(FINGERPRINT_LISTEN_SERVICE_NAME);
+ qdev->qchanfd = fd;
if (qdev->qchanfd < 0) {
ALOGE("listener cannot open fingerprint listener service exit");
pthread_mutex_unlock(&qdev->lock);