From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Richard Cochran <richardcochran@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
John Stultz <john.stultz@linaro.org>,
Arnd Bergmann <arnd@arndb.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH RESEND net] ptp: Ensure info->enable callback is always set
Date: Thu, 23 Jan 2025 10:38:37 +0100 [thread overview]
Message-ID: <Z5IOHVu9L+QpyK4Y@mev-dev.igk.intel.com> (raw)
In-Reply-To: <20250123-ptp-enable-v1-1-b015834d3a47@weissschuh.net>
On Thu, Jan 23, 2025 at 08:22:40AM +0100, Thomas Weißschuh wrote:
> The ioctl and sysfs handlers unconditionally call the ->enable callback.
> Not all drivers implement that callback, leading to NULL dereferences.
> Example of affected drivers: ptp_s390.c, ptp_vclock.c and ptp_mock.c.
>
> Instead use a dummy callback if no better was specified by the driver.
>
> Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> drivers/ptp/ptp_clock.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index b932425ddc6a3789504164a69d1b8eba47da462c..35a5994bf64f6373c08269d63aaeac3f4ab31ff0 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -217,6 +217,11 @@ static int ptp_getcycles64(struct ptp_clock_info *info, struct timespec64 *ts)
> return info->gettime64(info, ts);
> }
>
> +static int ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *request, int on)
> +{
> + return -EOPNOTSUPP;
> +}
> +
> static void ptp_aux_kworker(struct kthread_work *work)
> {
> struct ptp_clock *ptp = container_of(work, struct ptp_clock,
> @@ -294,6 +299,9 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
> ptp->info->getcrosscycles = ptp->info->getcrosststamp;
> }
>
> + if (!ptp->info->enable)
> + ptp->info->enable = ptp_enable;
> +
> if (ptp->info->do_aux_work) {
> kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker);
> ptp->kworker = kthread_run_worker(0, "ptp%d", ptp->index);
>
> ---
> base-commit: c4b9570cfb63501638db720f3bee9f6dfd044b82
> change-id: 20250122-ptp-enable-831339c62428
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
What about other ops, did you check it too? Looks like it isn't needed,
but it sometimes hard to follow.
Thanks
next prev parent reply other threads:[~2025-01-23 9:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 7:22 [PATCH RESEND net] ptp: Ensure info->enable callback is always set Thomas Weißschuh
2025-01-23 9:38 ` Michal Swiatkowski [this message]
2025-01-23 13:19 ` Thomas Weißschuh
2025-01-23 15:11 ` Richard Cochran
2025-01-27 22:40 ` patchwork-bot+netdevbpf
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=Z5IOHVu9L+QpyK4Y@mev-dev.igk.intel.com \
--to=michal.swiatkowski@linux.intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=john.stultz@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=stable@vger.kernel.org \
/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