aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/nfc/core.c')
-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);
560 * The device driver must call this function when one or many nfc targets 560 * The device driver must call this function when one or many nfc targets
561 * are found. After calling this function, the device driver must stop 561 * are found. After calling this function, the device driver must stop
562 * polling for targets. 562 * polling for targets.
563 * NOTE: This function can be called with targets=NULL and n_targets=0 to
564 * notify a driver error, meaning that the polling operation cannot complete.
563 * IMPORTANT: this function must not be called from an atomic context. 565 * IMPORTANT: this function must not be called from an atomic context.
564 * In addition, it must also not be called from a context that would prevent 566 * In addition, it must also not be called from a context that would prevent
565 * the NFC Core to call other nfc ops entry point concurrently. 567 * the NFC Core to call other nfc ops entry point concurrently.
@@ -586,13 +588,18 @@ int nfc_targets_found(struct nfc_dev *dev,
586 dev->targets_generation++; 588 dev->targets_generation++;
587 589
588 kfree(dev->targets); 590 kfree(dev->targets);
589 dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target), 591 dev->targets = NULL;
590 GFP_ATOMIC);
591 592
592 if (!dev->targets) { 593 if (targets) {
593 dev->n_targets = 0; 594 dev->targets = kmemdup(targets,
594 device_unlock(&dev->dev); 595 n_targets * sizeof(struct nfc_target),
595 return -ENOMEM; 596 GFP_ATOMIC);
597
598 if (!dev->targets) {
599 dev->n_targets = 0;
600 device_unlock(&dev->dev);
601 return -ENOMEM;
602 }
596 } 603 }
597 604
598 dev->n_targets = n_targets; 605 dev->n_targets = n_targets;