Skip to content

Commit 3c1c0f5

Browse files
Vincent CuissardSamuel Ortiz
authored andcommitted
NFC: NCI: Fix nci_register_device init sequence
All contexts have to be initiliazed before calling nfc_register_device otherwise it is possible to call nci_dev_up before ending the nci_register_device function. In such case kernel will crash on non initialized variables. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent cfdbeea commit 3c1c0f5

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎net/nfc/nci/core.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,18 +759,14 @@ int nci_register_device(struct nci_dev *ndev)
759759
struct device *dev = &ndev->nfc_dev->dev;
760760
char name[32];
761761

762-
rc = nfc_register_device(ndev->nfc_dev);
763-
if (rc)
764-
goto exit;
765-
766762
ndev->flags = 0;
767763

768764
INIT_WORK(&ndev->cmd_work, nci_cmd_work);
769765
snprintf(name, sizeof(name), "%s_nci_cmd_wq", dev_name(dev));
770766
ndev->cmd_wq = create_singlethread_workqueue(name);
771767
if (!ndev->cmd_wq) {
772768
rc = -ENOMEM;
773-
goto unreg_exit;
769+
goto exit;
774770
}
775771

776772
INIT_WORK(&ndev->rx_work, nci_rx_work);
@@ -800,6 +796,10 @@ int nci_register_device(struct nci_dev *ndev)
800796

801797
mutex_init(&ndev->req_lock);
802798

799+
rc = nfc_register_device(ndev->nfc_dev);
800+
if (rc)
801+
goto destroy_rx_wq_exit;
802+
803803
goto exit;
804804

805805
destroy_rx_wq_exit:
@@ -808,9 +808,6 @@ int nci_register_device(struct nci_dev *ndev)
808808
destroy_cmd_wq_exit:
809809
destroy_workqueue(ndev->cmd_wq);
810810

811-
unreg_exit:
812-
nfc_unregister_device(ndev->nfc_dev);
813-
814811
exit:
815812
return rc;
816813
}

0 commit comments

Comments
 (0)