Skip to content

Commit f7d07cd

Browse files
t-8chPaolo Abeni
authored andcommitted
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: 2050327 ("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>
1 parent 7b07b04 commit f7d07cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/ptp/ptp_vmclock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ static int vmclock_probe(struct platform_device *pdev)
525525
goto out;
526526
}
527527

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

591-
dev_set_drvdata(dev, st);
592-
593593
out:
594594
return ret;
595595
}

0 commit comments

Comments
 (0)