Commit 9171588c authored by Boris Brezillon's avatar Boris Brezillon Committed by Kleber Sacilotto de Souza

mtd: nand: denali: add missing nand_release() call in denali_remove()

BugLink: https://bugs.launchpad.net/bugs/1878232

commit 320092a0 upstream.

Unregister the NAND device from the NAND subsystem when removing a denali
NAND controller, otherwise the MTD attached to the NAND device is still
exposed by the MTD layer, and accesses to this device will likely crash
the system.

Fixes: 2a0a288e ("mtd: denali: split the generic driver and PCI layer")
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: default avatarDinh Nguyen <dinguyen@opensource.altera.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 7d8a503d
...@@ -1622,9 +1622,16 @@ EXPORT_SYMBOL(denali_init); ...@@ -1622,9 +1622,16 @@ EXPORT_SYMBOL(denali_init);
/* driver exit point */ /* driver exit point */
void denali_remove(struct denali_nand_info *denali) void denali_remove(struct denali_nand_info *denali)
{ {
/*
* Pre-compute DMA buffer size to avoid any problems in case
* nand_release() ever changes in a way that mtd->writesize and
* mtd->oobsize are not reliable after this call.
*/
int bufsize = denali->mtd.writesize + denali->mtd.oobsize;
nand_release(&denali->mtd);
denali_irq_cleanup(denali->irq, denali); denali_irq_cleanup(denali->irq, denali);
dma_unmap_single(denali->dev, denali->buf.dma_buf, dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
denali->mtd.writesize + denali->mtd.oobsize,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
} }
EXPORT_SYMBOL(denali_remove); EXPORT_SYMBOL(denali_remove);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment