Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 822e423e authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Darren Hart (VMware)
Browse files

platform/x86: intel_scu_ipc: Rearrange init sequence



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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent ac207ded
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -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);