--- x/net/nfc/nci/core.c +++ n/net/nfc/nci/core.c @@ -559,6 +559,8 @@ static int nci_close_device(struct nci_d */ mutex_lock(&ndev->req_lock); + set_bit(NCI_UNREG, &ndev->flags); + if (!test_and_clear_bit(NCI_UP, &ndev->flags)) { /* Need to flush the cmd wq in case * there is a queued/running cmd_work @@ -598,9 +600,6 @@ static int nci_close_device(struct nci_d del_timer_sync(&ndev->cmd_timer); - /* Clear flags except NCI_UNREG */ - ndev->flags &= BIT(NCI_UNREG); - mutex_unlock(&ndev->req_lock); return 0; @@ -1282,12 +1281,6 @@ void nci_unregister_device(struct nci_de { struct nci_conn_info *conn_info, *n; - /* This set_bit is not protected with specialized barrier, - * However, it is fine because the mutex_lock(&ndev->req_lock); - * in nci_close_device() will help to emit one. - */ - set_bit(NCI_UNREG, &ndev->flags); - nci_close_device(ndev); destroy_workqueue(ndev->cmd_wq);