[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241125105954.1509971-1-ajay.kaher@broadcom.com>
Date: Mon, 25 Nov 2024 10:59:54 +0000
From: Ajay Kaher <ajay.kaher@...adcom.com>
To: richardcochran@...il.com,
netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
nick.shi@...adcom.com,
ajay.kaher@...adcom.com,
alexey.makhalov@...adcom.com,
vasavi.sirnapalli@...adcom.com,
vamsi-krishna.brahmajosyula@...adcom.com,
florian.fainelli@...adcom.com
Subject: [PATCH] ptp: Add error handling for adjfine callback in ptp_clock_adjtime
ptp_clock_adjtime sets ptp->dialed_frequency even when adjfine
callback returns an error. This causes subsequent reads to return
an incorrect value.
Fix this by adding error check before ptp->dialed_frequency is set.
Fixes: 39a8cbd9ca05 ("ptp: remember the adjusted frequency")
Signed-off-by: Ajay Kaher <ajay.kaher@...adcom.com>
---
drivers/ptp/ptp_clock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index c56cd0f..77a36e7 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -150,7 +150,8 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
if (ppb > ops->max_adj || ppb < -ops->max_adj)
return -ERANGE;
err = ops->adjfine(ops, tx->freq);
- ptp->dialed_frequency = tx->freq;
+ if (!err)
+ ptp->dialed_frequency = tx->freq;
} else if (tx->modes & ADJ_OFFSET) {
if (ops->adjphase) {
s32 max_phase_adj = ops->getmaxphase(ops);
--
2.39.4
Powered by blists - more mailing lists