Skip to content

Commit 39e926c

Browse files
t-8chPaolo Abeni
authored andcommitted
ptp: vmclock: Don't unregister misc device if it was not registered
vmclock_remove() tries to detect the successful registration of the misc device based on the value of its minor value. However that check is incorrect if the misc device registration was not attempted in the first place. Always initialize the minor number, so the check works properly. 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> 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 f7d07cd commit 39e926c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/ptp/ptp_vmclock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,15 @@ static int vmclock_probe(struct platform_device *pdev)
550550
goto out;
551551
}
552552

553+
st->miscdev.minor = MISC_DYNAMIC_MINOR;
554+
553555
/*
554556
* If the structure is big enough, it can be mapped to userspace.
555557
* Theoretically a guest OS even using larger pages could still
556558
* use 4KiB PTEs to map smaller MMIO regions like this, but let's
557559
* cross that bridge if/when we come to it.
558560
*/
559561
if (le32_to_cpu(st->clk->size) >= PAGE_SIZE) {
560-
st->miscdev.minor = MISC_DYNAMIC_MINOR;
561562
st->miscdev.fops = &vmclock_miscdev_fops;
562563
st->miscdev.name = st->name;
563564

0 commit comments

Comments
 (0)