diff options
author | Vincent Cuissard <cuissard@marvell.com> | 2014-07-22 13:48:39 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-09-01 08:40:37 -0400 |
commit | 3c1c0f5dc80bbde5baef2403cc6a0d33c9824d2d (patch) | |
tree | bd2bf21f0a1d71635d7dd8ea17ad9ad7b7a75001 /net/nfc | |
parent | cfdbeeafdbbdbc006f700e92cbad2cb5d4529f3d (diff) |
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>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/nci/core.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 860080803a3e..90b16cb40058 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -759,10 +759,6 @@ int nci_register_device(struct nci_dev *ndev) | |||
759 | struct device *dev = &ndev->nfc_dev->dev; | 759 | struct device *dev = &ndev->nfc_dev->dev; |
760 | char name[32]; | 760 | char name[32]; |
761 | 761 | ||
762 | rc = nfc_register_device(ndev->nfc_dev); | ||
763 | if (rc) | ||
764 | goto exit; | ||
765 | |||
766 | ndev->flags = 0; | 762 | ndev->flags = 0; |
767 | 763 | ||
768 | INIT_WORK(&ndev->cmd_work, nci_cmd_work); | 764 | INIT_WORK(&ndev->cmd_work, nci_cmd_work); |
@@ -770,7 +766,7 @@ int nci_register_device(struct nci_dev *ndev) | |||
770 | ndev->cmd_wq = create_singlethread_workqueue(name); | 766 | ndev->cmd_wq = create_singlethread_workqueue(name); |
771 | if (!ndev->cmd_wq) { | 767 | if (!ndev->cmd_wq) { |
772 | rc = -ENOMEM; | 768 | rc = -ENOMEM; |
773 | goto unreg_exit; | 769 | goto exit; |
774 | } | 770 | } |
775 | 771 | ||
776 | INIT_WORK(&ndev->rx_work, nci_rx_work); | 772 | INIT_WORK(&ndev->rx_work, nci_rx_work); |
@@ -800,6 +796,10 @@ int nci_register_device(struct nci_dev *ndev) | |||
800 | 796 | ||
801 | mutex_init(&ndev->req_lock); | 797 | mutex_init(&ndev->req_lock); |
802 | 798 | ||
799 | rc = nfc_register_device(ndev->nfc_dev); | ||
800 | if (rc) | ||
801 | goto destroy_rx_wq_exit; | ||
802 | |||
803 | goto exit; | 803 | goto exit; |
804 | 804 | ||
805 | destroy_rx_wq_exit: | 805 | destroy_rx_wq_exit: |
@@ -808,9 +808,6 @@ destroy_rx_wq_exit: | |||
808 | destroy_cmd_wq_exit: | 808 | destroy_cmd_wq_exit: |
809 | destroy_workqueue(ndev->cmd_wq); | 809 | destroy_workqueue(ndev->cmd_wq); |
810 | 810 | ||
811 | unreg_exit: | ||
812 | nfc_unregister_device(ndev->nfc_dev); | ||
813 | |||
814 | exit: | 811 | exit: |
815 | return rc; | 812 | return rc; |
816 | } | 813 | } |