diff options
author | Thomas Weißschuh <thomas.weissschuh@linutronix.de> | 2025-02-07 12:39:03 +0300 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2025-02-11 12:20:52 +0300 |
commit | f7d07cd4f77d77f366c8ffbb8ba8b61f614e5fce (patch) | |
tree | 08ac96843033b1a2b8423f5e594d60d3b3c17f63 | |
parent | 7b07b040257c1b658ef3eca86e4b6ae02d65069c (diff) | |
download | linux-f7d07cd4f77d77f366c8ffbb8ba8b61f614e5fce.tar.xz |
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: 205032724226 ("ptp: Add support for the AMZNC10C 'vmclock' device")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r-- | drivers/ptp/ptp_vmclock.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index dbc73e538293..1ba30a2da570 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -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; } |