]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
ptp: vmclock: Set driver data before its usage
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Fri, 7 Feb 2025 09:39:03 +0000 (10:39 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 11 Feb 2025 09:20:52 +0000 (10:20 +0100)
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>
drivers/ptp/ptp_vmclock.c

index dbc73e5382935dcbc799ea608b87f5ff51044ebc..1ba30a2da570fb4d1ec9db72820bf1781dfa9655 100644 (file)
@@ -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;
 }