aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@intel.com>2012-05-03 16:33:32 +0200
committerJohn W. Linville <linville@tuxdriver.com>2012-07-09 16:42:10 -0400
commitd94f9c55ff22397cc3436840437da533e9263716 (patch)
treeef025e33201553d5701c85a2c6ab58e1c52c58ce /net/nfc
parentNFC: Core must test the device polling state inside the device lock (diff)
downloadlinux-dev-d94f9c55ff22397cc3436840437da533e9263716.tar.xz
linux-dev-d94f9c55ff22397cc3436840437da533e9263716.zip
NFC: nfc_targets_found() should accept zero target found
The semantics for a zero target found event is that the polling operation could not complete. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/core.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 94ccf07374a5..749ee48d3600 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -560,6 +560,8 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
* The device driver must call this function when one or many nfc targets
* are found. After calling this function, the device driver must stop
* polling for targets.
+ * NOTE: This function can be called with targets=NULL and n_targets=0 to
+ * notify a driver error, meaning that the polling operation cannot complete.
* IMPORTANT: this function must not be called from an atomic context.
* In addition, it must also not be called from a context that would prevent
* the NFC Core to call other nfc ops entry point concurrently.
@@ -586,13 +588,18 @@ int nfc_targets_found(struct nfc_dev *dev,
dev->targets_generation++;
kfree(dev->targets);
- dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target),
- GFP_ATOMIC);
+ dev->targets = NULL;
- if (!dev->targets) {
- dev->n_targets = 0;
- device_unlock(&dev->dev);
- return -ENOMEM;
+ if (targets) {
+ dev->targets = kmemdup(targets,
+ n_targets * sizeof(struct nfc_target),
+ GFP_ATOMIC);
+
+ if (!dev->targets) {
+ dev->n_targets = 0;
+ device_unlock(&dev->dev);
+ return -ENOMEM;
+ }
}
dev->n_targets = n_targets;