[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250207-vmclock-probe-v2-2-bc2fce0bdf07@linutronix.de>
Date: Fri, 07 Feb 2025 10:39:03 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: David Woodhouse <dwmw2@...radead.org>,
Richard Cochran <richardcochran@...il.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Cc: Mateusz Polchlopek <mateusz.polchlopek@...el.com>,
David Woodhouse <dwmw@...zon.co.uk>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
stable@...r.kernel.org
Subject: [PATCH net v2 2/5] 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@...r.kernel.org
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@...el.com>
Acked-by: Richard Cochran <richardcochran@...il.com>
Reviewed-by: David Woodhouse <dwmw@...zon.co.uk>
---
drivers/ptp/ptp_vmclock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c
index dbc73e5382935dcbc799ea608b87f5ff51044ebc..1ba30a2da570fb4d1ec9db72820bf1781dfa9655 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;
}
--
2.48.1
Powered by blists - more mailing lists