diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c index 448e5a4e73..386dcd4ff7 100644 --- a/drivers/nfc/nxp-nci/core.c +++ b/drivers/nfc/nxp-nci/core.c @@ -186,15 +186,18 @@ void nxp_nci_remove(struct nci_dev *ndev) nxp_nci_fw_work_complete(info, -ESHUTDOWN); cancel_work_sync(&info->fw_info.work); - mutex_lock(&info->info_lock); + /* + * nci_unregister_device() closes an open device through + * nxp_nci_close(), which takes info_lock itself: unregister first. + */ + nci_unregister_device(ndev); + mutex_lock(&info->info_lock); if (info->phy_ops->set_mode) info->phy_ops->set_mode(info->phy_id, NXP_NCI_MODE_COLD); + mutex_unlock(&info->info_lock); - nci_unregister_device(ndev); nci_free_device(ndev); - - mutex_unlock(&info->info_lock); } EXPORT_SYMBOL(nxp_nci_remove);