net/mlx5: Fix turn-off PPS command
authorAya Levin <ayal@nvidia.com>
Mon, 1 Mar 2021 15:54:21 +0000 (17:54 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 10 Mar 2021 19:01:54 +0000 (11:01 -0800)
Fix a bug of uninitialized pin index when trying to turn off PPS out.

Fixes: de19cd6cc977 ("net/mlx5: Move some PPS logic into helper functions")
Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Eran Ben Elisha <eranbe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

index b0e129d..1e7f26b 100644 (file)
@@ -495,15 +495,15 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
                return -EINVAL;
 
        field_select = MLX5_MTPPS_FS_ENABLE;
+       pin = ptp_find_pin(clock->ptp, PTP_PF_PEROUT, rq->perout.index);
+       if (pin < 0)
+               return -EBUSY;
+
        if (on) {
                bool rt_mode = mlx5_real_time_mode(mdev);
                u32 nsec;
                s64 sec;
 
-               pin = ptp_find_pin(clock->ptp, PTP_PF_PEROUT, rq->perout.index);
-               if (pin < 0)
-                       return -EBUSY;
-
                pin_mode = MLX5_PIN_MODE_OUT;
                pattern = MLX5_OUT_PATTERN_PERIODIC;
                ts.tv_sec = rq->perout.period.sec;