From 9a0a10826bd811b181669ae9eb4544c5c4136bff Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Tue, 28 Jan 2014 10:25:29 +0100 Subject: [PATCH] Fix pn53x_initiator_target_is_present() when saved target is NULL This patch prevents from running any command to check target presence when none have been saved --- libnfc/chips/pn53x.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 690c0d1..56679ea 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1728,6 +1728,11 @@ pn53x_initiator_deselect_target(struct nfc_device *pnd) int pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt) { + // Check if there is a saved target + if (CHIP_DATA(pnd)->current_target == NULL) { + return NFC_ETGRELEASED; + } + // Check if the argument target nt is equals to current saved target if ((pnt != NULL) && (!pn53x_current_target_is(pnd, pnt))) { return NFC_ETGRELEASED;