From: Jakub Kicinski <kuba@kernel.org>
To: itazur@amazon.com
Cc: Jakub Kicinski <kuba@kernel.org>,
graf@amazon.de, itazur@amazon.co.uk, conor+dt@kernel.org,
dwmw2@infradead.org, devicetree@vger.kernel.org,
xmarcalx@amazon.co.uk, linux-kernel@vger.kernel.org,
edumazet@google.com, robh@kernel.org, richardcochran@gmail.com,
andrew+netdev@lunn.ch, mzxreary@0pointer.de, pabeni@redhat.com,
dwmw@amazon.co.uk, netdev@vger.kernel.org, krzk+dt@kernel.org,
davem@davemloft.net, mail@bchalios.io
Subject: Re: [v6,2/7] ptp: vmclock: support device notifications
Date: Thu, 22 Jan 2026 19:11:34 -0800 [thread overview]
Message-ID: <20260123031133.3059291-2-kuba@kernel.org> (raw)
In-Reply-To: <20260121143402.3092-3-itazur@amazon.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ptp: vmclock: support device notifications
This patch adds optional device notification support to VMClock, allowing
the hypervisor to notify the driver when seq_count changes. It also adds
poll() support to propagate these notifications to userspace.
> diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c
> index b3a83b03d9c1..38b2bacb755e 100644
> --- a/drivers/ptp/ptp_vmclock.c
> +++ b/drivers/ptp/ptp_vmclock.c
[ ... ]
> +static void
> +vmclock_acpi_notification_handler(acpi_handle __always_unused handle,
> + u32 __always_unused event, void *dev)
> +{
> + struct device *device = dev;
> + struct vmclock_state *st = device->driver_data;
> +
> + wake_up_interruptible(&st->disrupt_wait);
> +}
> +
> +static int vmclock_setup_notification(struct device *dev, struct vmclock_state *st)
> +{
[ ... ]
> + status = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
> + vmclock_acpi_notification_handler,
> + dev);
Since acpi_install_notify_handler() is called here, should there be a
corresponding acpi_remove_notify_handler() in vmclock_remove()? Currently
the handler remains registered after device removal, which could lead to
a use-after-free if the hypervisor sends a notification after the driver
state has been freed.
[ ... ]
> @@ -549,6 +653,11 @@ static int vmclock_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + init_waitqueue_head(&st->disrupt_wait);
> + ret = vmclock_setup_notification(dev, st);
> + if (ret)
> + return ret;
[ ... ]
> @@ -581,6 +690,8 @@ static int vmclock_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> + dev->driver_data = st;
Is there a race window here? The ACPI notification handler is installed
in vmclock_setup_notification() which runs earlier in vmclock_probe(),
but the handler accesses device->driver_data. If the hypervisor sends a
notification between vmclock_setup_notification() and this assignment,
vmclock_acpi_notification_handler() would dereference NULL or garbage.
I see this is fixed later in the series by commit 47fdd294385e which
moves dev->driver_data = st before vmclock_setup_notification().
--
pw-bot: cr
next prev parent reply other threads:[~2026-01-23 3:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 14:33 [PATCH v6 0/7] ptp: vmclock: Add VM generation counter and ACPI notification Takahiro Itazuri
2026-01-21 14:33 ` [PATCH v6 1/7] ptp: vmclock: add vm generation counter Takahiro Itazuri
2026-01-21 14:33 ` [PATCH v6 2/7] ptp: vmclock: support device notifications Takahiro Itazuri
2026-01-23 3:11 ` Jakub Kicinski [this message]
2026-01-23 20:16 ` [v6,2/7] " David Woodhouse
2026-01-21 14:33 ` [PATCH v6 3/7] dt-bindings: ptp: Add amazon,vmclock Takahiro Itazuri
2026-01-21 14:33 ` [PATCH v6 4/7] ptp: ptp_vmclock: Add device tree support Takahiro Itazuri
2026-01-21 14:33 ` [PATCH v6 5/7] ptp: ptp_vmclock: add 'VMCLOCK' to ACPI device match Takahiro Itazuri
2026-01-21 14:33 ` [PATCH v6 6/7] ptp: ptp_vmclock: remove dependency on CONFIG_ACPI Takahiro Itazuri
2026-01-21 14:33 ` [PATCH v6 7/7] ptp: ptp_vmclock: return TAI not UTC Takahiro Itazuri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260123031133.3059291-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=dwmw@amazon.co.uk \
--cc=edumazet@google.com \
--cc=graf@amazon.de \
--cc=itazur@amazon.co.uk \
--cc=itazur@amazon.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@bchalios.io \
--cc=mzxreary@0pointer.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=xmarcalx@amazon.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox