From 1d98729ccc4123ea1cff7fbaa56fe77b0575f873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Mon, 3 Dec 2012 09:57:25 +0200 Subject: [PATCH 2/3] imgdev: fix cancelling of enrollment from stage_completed callback Re-check device state after fpi_drvcb_enroll_stage_completed(). If enrollment was cancelled after non-completing stage, we must not restart acquire as it would confuse the internal state machine. --- libfprint/imgdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libfprint/imgdev.c b/libfprint/imgdev.c index 14e41ae..1ed3f6d 100644 --- a/libfprint/imgdev.c +++ b/libfprint/imgdev.c @@ -145,7 +145,10 @@ void fpi_imgdev_report_finger_status(struct fp_img_dev *imgdev, case IMG_ACTION_ENROLL: fp_dbg("reporting enroll result"); fpi_drvcb_enroll_stage_completed(imgdev->dev, r, data, img); - if (r > 0 && r != FP_ENROLL_COMPLETE && r != FP_ENROLL_FAIL) { + /* the callback can cancel enrollment, so recheck current + * action and the status to see if retry is needed */ + if (imgdev->action == IMG_ACTION_ENROLL && + r > 0 && r != FP_ENROLL_COMPLETE && r != FP_ENROLL_FAIL) { imgdev->action_result = 0; imgdev->action_state = IMG_ACQUIRE_STATE_AWAIT_FINGER_ON; dev_change_state(imgdev, IMG_ACQUIRE_STATE_AWAIT_FINGER_ON); -- 1.8.0.1