mlx5: Reject requests to enable time stamping on both edges.
authorRichard Cochran <richardcochran@gmail.com>
Thu, 14 Nov 2019 18:45:06 +0000 (10:45 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Nov 2019 20:48:33 +0000 (12:48 -0800)
This driver enables rising edge or falling edge, but not both, and so
this patch validates that the request contains only one of the two
edges.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

index 819097d9b583b3c9acf3cb93b3355abd51696d84..43f97601b50001d8cffb3f2a0b67974bbb277240 100644 (file)
@@ -243,6 +243,12 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp,
                                PTP_STRICT_FLAGS))
                return -EOPNOTSUPP;
 
+       /* Reject requests to enable time stamping on both edges. */
+       if ((rq->extts.flags & PTP_STRICT_FLAGS) &&
+           (rq->extts.flags & PTP_ENABLE_FEATURE) &&
+           (rq->extts.flags & PTP_EXTTS_EDGES) == PTP_EXTTS_EDGES)
+               return -EOPNOTSUPP;
+
        if (rq->extts.index >= clock->ptp_info.n_pins)
                return -EINVAL;