On Thu, 7 May 2020 13:00:33 +0200 Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote: > + > +static void anfc_chips_cleanup(struct arasan_nfc *nfc) > +{ > + struct anand *anand, *tmp; > + > + list_for_each_entry_safe(anand, tmp, &nfc->chips, node) { > + nand_release(&anand->chip); ret = mtd_device_unregister(nand_to_mtd(&anand->chip)); WARN_ON(ret); nand_cleanup(&anand->chip); Or maybe add this WARN_ON() to nand_release() so we don't have to ask people to use mtd_device_unregister() + nand_cleanup(). We really should fix that at some point (allocate nand_chip and mtd_info separately and leave a dummy mtd_info object with all hooks returning ENODEV when the unregister fails). > + list_del(&anand->node); > + } > +}