• Josh Wu's avatar
    mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected · 8a631f3a
    Josh Wu authored
    commit a749d13a upstream.
    
    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: default avatarJosh Wu <josh.wu@atmel.com>
    Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    8a631f3a
atmel_nand.c 58.9 KB