Commit f7d07cd4 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Paolo Abeni
Browse files

ptp: vmclock: Set driver data before its usage



If vmclock_ptp_register() fails during probing, vmclock_remove() is
called to clean up the ptp clock and misc device.
It uses dev_get_drvdata() to access the vmclock state.
However the driver data is not yet set at this point.

Assign the driver data earlier.

Fixes: 20503272 ("ptp: Add support for the AMZNC10C 'vmclock' device")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarThomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: default avatarMateusz Polchlopek <mateusz.polchlopek@intel.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Reviewed-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 7b07b040
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -525,6 +525,8 @@ static int vmclock_probe(struct platform_device *pdev)
		goto out;
	}

	dev_set_drvdata(dev, st);

	if (le32_to_cpu(st->clk->magic) != VMCLOCK_MAGIC ||
	    le32_to_cpu(st->clk->size) > resource_size(&st->res) ||
	    le16_to_cpu(st->clk->version) != 1) {
@@ -588,8 +590,6 @@ static int vmclock_probe(struct platform_device *pdev)
		 (st->miscdev.minor && st->ptp_clock) ? ", " : "",
		 st->ptp_clock ? "PTP" : "");

	dev_set_drvdata(dev, st);

 out:
	return ret;
}