]> www.infradead.org Git - users/dwmw2/vmclock.git/commitdiff
ptp: vmclock: Don't unregister misc device if it was not registered
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Fri, 7 Feb 2025 09:39:04 +0000 (10:39 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 29 Apr 2025 16:59:10 +0000 (09:59 -0700)
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: 205032724226 ("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>
(cherry picked from commit 39e926c3a21b25af6cae479fbb752f193240ce03)

ptp_vmclock.c

index a74e79e368e6fd42512c929b97013fbe509cb78c..c998130c49570fd1c255f6f3fdb838adf5e12364 100644 (file)
@@ -564,6 +564,8 @@ static int vmclock_probe(struct platform_device *pdev)
                goto out;
        }
 
+       st->miscdev.minor = MISC_DYNAMIC_MINOR;
+
        /*
         * If the structure is big enough, it can be mapped to userspace.
         * Theoretically a guest OS even using larger pages could still
@@ -571,7 +573,6 @@ static int vmclock_probe(struct platform_device *pdev)
         * cross that bridge if/when we come to it.
         */
        if (le32_to_cpu(st->clk->size) >= PAGE_SIZE) {
-               st->miscdev.minor = MISC_DYNAMIC_MINOR;
                st->miscdev.fops = &vmclock_miscdev_fops;
                st->miscdev.name = st->name;