]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected
authorJosh Wu <josh.wu@atmel.com>
Tue, 5 Nov 2013 09:59:07 +0000 (17:59 +0800)
committerBrian Norris <computersforpeace@gmail.com>
Thu, 7 Nov 2013 18:16:21 +0000 (10:16 -0800)
In the atmel driver probe function, the code shows like following:
  atmel_nand_probe(...) {
        ...

  err_nand_ioremap:
        platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
  }

If no nand flash detected, the driver probe function will goto
err_nand_ioremap label.
Then platform_driver_unregister() will be called. It will get the
lock of atmel_nand device since it is parent of nfc_device. The
problem is the lock is already hold by atmel_nand_probe itself.
So system will be in a dead lock.

This patch just simply removed to platform_driver_unregister() call.
When atmel_nand driver is quit the platform_driver_unregister() will
be called in atmel_nand_remove().

[Brian: the NAND platform probe really has no business
 registering/unregistering another driver; this fixes the deadlock, but
 we should follow up the likely racy behavior here with a better
 architecture]

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Cc: <stable@vger.kernel.org> # 3.12
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/atmel_nand.c

index ef9c9f547c01fffe391235e3a6d9dffe95944321..469d4e2c450a887e7b896b372b915c33d6c5aeb3 100644 (file)
@@ -2142,7 +2142,6 @@ err_no_card:
        if (host->dma_chan)
                dma_release_channel(host->dma_chan);
 err_nand_ioremap:
-       platform_driver_unregister(&atmel_nand_nfc_driver);
        return res;
 }