All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Miroslav Lichvar <mlichvar@redhat.com>
Cc: netdev@vger.kernel.org,
	Richard Cochran <richardcochran@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <jstultz@google.com>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH RESEND net-next] ptp: Limit time setting of PTP clocks
Date: Wed, 27 Aug 2025 17:37:08 -0700	[thread overview]
Message-ID: <20250827173708.398bdb99@kernel.org> (raw)
In-Reply-To: <20250825111117.3846097-1-mlichvar@redhat.com>

On Mon, 25 Aug 2025 13:11:13 +0200 Miroslav Lichvar wrote:
> -		if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
> +		/* Make sure the offset is valid */
> +		err = ptp_clock_gettime(pc, &ts2);
> +		if (err)
> +			return err;
> +		ts2 = timespec64_add(ts2, ts);
> +
> +		if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC ||
> +		    !timespec64_valid_settod(&ts2))
>  			return -EINVAL;

Please leave the input validation (tv_nsec >= NSEC_PER_SEC)
separate and before we call gettime. It's easy to miss that
on part of the condition is checking ts and the other ts2.

Do we not need to apply the same treatment to adjphase?
-- 
pw-bot: cr

  reply	other threads:[~2025-08-28  0:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25 11:11 [PATCH RESEND net-next] ptp: Limit time setting of PTP clocks Miroslav Lichvar
2025-08-28  0:37 ` Jakub Kicinski [this message]
2025-08-28 10:11   ` Miroslav Lichvar

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=20250827173708.398bdb99@kernel.org \
    --to=kuba@kernel.org \
    --cc=arnd@arndb.de \
    --cc=jstultz@google.com \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.