dp83640: Reject requests to enable time stamping on both edges.
authorRichard Cochran <richardcochran@gmail.com>
Thu, 14 Nov 2019 18:45:04 +0000 (10:45 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Nov 2019 20:48:32 +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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/dp83640.c

index 3bba2bea3a885c14e8a59605ba782ad7b95ab720..8f241b57fcf65b0d5872fede555c2ab761a358d3 100644 (file)
@@ -475,6 +475,13 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
                                        PTP_FALLING_EDGE |
                                        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;
+
                index = rq->extts.index;
                if (index >= N_EXT_TS)
                        return -EINVAL;