Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617103

[PATCH v1 2/5] platform/x86: intel_scu_ipc: Rearrange init sequence

From Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v1 2/5] platform/x86: intel_scu_ipc: Rearrange init sequence
Date 2017-04-05 18:10 +0200
Message-ID <tsVFq-4Pz-53@gated-at.bofh.it> (permalink)
References <tsVFo-4Pz-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Device pointer is used as a flag that everything is prepared.
Nevertheless the assignment happened quite before and there is a window
when a caller can get weird results or even crashes since not all fields
are initialized yet.

Rearrange initialization sequence in ->probe() to prepare everything
before use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_scu_ipc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index d789fe1baf17..8a34c1e7536f 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -582,7 +582,6 @@ static int ipc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!pdata)
 		return -ENODEV;
 
-	scu->dev = &pdev->dev;
 	scu->irq_mode = pdata->irq_mode;
 
 	err = pcim_enable_device(pdev);
@@ -595,17 +594,20 @@ static int ipc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	init_completion(&scu->cmd_complete);
 
-	err = devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_scu_ipc",
-			       scu);
-	if (err)
-		return err;
-
 	scu->ipc_base = pcim_iomap_table(pdev)[0];
 
 	scu->i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len);
 	if (!scu->i2c_base)
 		return -ENOMEM;
 
+	err = devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_scu_ipc",
+			       scu);
+	if (err)
+		return err;
+
+	/* Assign device at last */
+	scu->dev = &pdev->dev;
+
 	intel_scu_devices_create();
 
 	pci_set_drvdata(pdev, scu);
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v1 1/5] platform/x86: intel_scu_ipc: Platform data is mandatory Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-04-05 18:10 +0200
  [PATCH v1 3/5] platform/x86: intel_scu_ipc: Remove redundant subarch check Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-04-05 18:10 +0200
  [PATCH v1 2/5] platform/x86: intel_scu_ipc: Rearrange init sequence Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-04-05 18:10 +0200
  [PATCH v1 5/5] platform/x86: intel_scu_ipc: Introduce intel_scu_ipc_raw_command() Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-04-05 18:10 +0200

csiph-web