From: Vladimir Oltean <olteanv@gmail.com>
To: kuba@kernel.org, davem@davemloft.net, netdev@vger.kernel.org
Cc: richardcochran@gmail.com, jacob.e.keller@intel.com
Subject: [PATCH net-next] ptp: only allow phase values lower than 1 period
Date: Mon, 3 Aug 2020 22:49:21 +0300 [thread overview]
Message-ID: <20200803194921.603151-1-olteanv@gmail.com> (raw)
The way we define the phase (the difference between the time of the
signal's rising edge, and the closest integer multiple of the period),
it doesn't make sense to have a phase value larger than 1 period.
So deny these settings coming from the user.
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
drivers/ptp/ptp_chardev.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index e0e6f85966e1..02fcd5e8b998 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -218,6 +218,19 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
break;
}
}
+ if (perout->flags & PTP_PEROUT_PHASE) {
+ /*
+ * The phase should be specified modulo the
+ * period, therefore anything larger than 1
+ * period is invalid.
+ */
+ if (perout->phase.sec > perout->period.sec ||
+ (perout->phase.sec == perout->period.sec &&
+ perout->phase.nsec > perout->period.nsec)) {
+ err = -ERANGE;
+ break;
+ }
+ }
} else if (cmd == PTP_PEROUT_REQUEST) {
req.perout.flags &= PTP_PEROUT_V1_VALID_FLAGS;
req.perout.rsv[0] = 0;
--
2.25.1
next reply other threads:[~2020-08-03 19:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 19:49 Vladimir Oltean [this message]
2020-08-04 1:18 ` [PATCH net-next] ptp: only allow phase values lower than 1 period David Miller
2020-08-04 23:04 ` David Miller
2020-08-04 23:23 ` Richard Cochran
2020-08-04 23:40 ` Vladimir Oltean
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=20200803194921.603151-1-olteanv@gmail.com \
--to=olteanv@gmail.com \
--cc=davem@davemloft.net \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
/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