From 29e18feaf6b050bafabb46a35a8da995872fe0bf Mon Sep 17 00:00:00 2001
From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Tue, 18 May 2021 23:37:29 +0300
Subject: [PATCH] net: ethernet: ti: icss_iep: sr2.0 fix NULL pointer exception
 on pps stop

The NULL pointer exception is observed on pps stop - fix it as timer is not
used for SR2.0.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/net/ethernet/ti/icss_iep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/icss_iep.c b/drivers/net/ethernet/ti/icss_iep.c
index eec7e9fb1f61..0ed54c8251e2 100644
--- a/drivers/net/ethernet/ti/icss_iep.c
+++ b/drivers/net/ethernet/ti/icss_iep.c
@@ -553,7 +553,8 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
 		goto exit;
 
 	spin_lock_irqsave(&iep->irq_lock, flags);
-	hrtimer_cancel(&iep->sync_timer);
+	if (iep->cap_cmp_irq)
+		hrtimer_cancel(&iep->sync_timer);
 	ret = icss_iep_perout_enable_hw(iep, req, on);
 	if (!ret)
 		iep->perout_enabled = !!on;
@@ -667,7 +668,8 @@ static int icss_iep_pps_enable(struct icss_iep *iep, int on)
 		rq.perout.start.nsec = 0;
 		ret = icss_iep_perout_enable_hw(iep, &rq.perout, on);
 	} else {
-		hrtimer_cancel(&iep->sync_timer);
+		if (iep->cap_cmp_irq)
+			hrtimer_cancel(&iep->sync_timer);
 		ret = icss_iep_perout_enable_hw(iep, &rq.perout, on);
 	}
 
