NFC: Remove and free all SEs when releasing an NFC device
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 10 May 2013 13:53:29 +0000 (15:53 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 14 Jun 2013 11:45:00 +0000 (13:45 +0200)
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/core.c

index bb5f16cfc2016e8c7fcb759f63962f1d3b90d95a..5b60b9ddfc8f30a56b9df1bead13d12e57163c87 100644 (file)
@@ -820,11 +820,19 @@ EXPORT_SYMBOL(nfc_remove_se);
 static void nfc_release(struct device *d)
 {
        struct nfc_dev *dev = to_nfc_dev(d);
+       struct nfc_se *se, *n;
 
        pr_debug("dev_name=%s\n", dev_name(&dev->dev));
 
        nfc_genl_data_exit(&dev->genl_data);
        kfree(dev->targets);
+
+       list_for_each_entry_safe(se, n, &dev->secure_elements, list) {
+                       nfc_genl_se_removed(dev, se->idx);
+                       list_del(&se->list);
+                       kfree(se);
+       }
+
        kfree(dev);
 }