From 8668fdd6efb3a75e0d58a3287a47fa7e60a68a73 Mon Sep 17 00:00:00 2001 From: Eric Lapuyade Date: Thu, 3 May 2012 16:21:58 +0200 Subject: NFC: Core must test the device polling state inside the device lock There can ever be only one call to nfc_targets_found() after polling has been engaged. This could be from a target discovered event from the driver, or from an error handler to notify poll will never complete. Signed-off-by: Eric Lapuyade Signed-off-by: Samuel Ortiz --- net/nfc/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'net/nfc') diff --git a/net/nfc/core.c b/net/nfc/core.c index 32f28326b623..94ccf07374a5 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -571,13 +571,18 @@ int nfc_targets_found(struct nfc_dev *dev, pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets); - dev->polling = false; - for (i = 0; i < n_targets; i++) targets[i].idx = dev->target_next_idx++; device_lock(&dev->dev); + if (dev->polling == false) { + device_unlock(&dev->dev); + return 0; + } + + dev->polling = false; + dev->targets_generation++; kfree(dev->targets); -- cgit v1.2.3-59-g8ed1b