Skip to contentSkip to conversation

ptp: Add error handling for adjfine callback in ptp_clock_adjtime

PATCH Applied Ajay Kaher 3 participants 3 messages Nov 25, 2024 – Nov 30, 2024

Subsystems (3)
lore
Share & tools
lore

Ajay Kaher

author
#0 lore raw

PATCH 1/1 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")
---
 drivers/ptp/ptp_clock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ptp/ptp_clock.c +2 -1
index c56cd0f..77a36e7 100644
@@ -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);
Signature · 1 line
2.39.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ajay Kaher

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")
#2 lore raw
In reply to Ajay Kaher
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Mon, 25 Nov 2024 10:59:54 +0000 you wrote:

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")

[...]

Here is the summary with links:
- ptp: Add error handling for adjfine callback in ptp_clock_adjtime

    https://git.kernel.org/netdev/net/c/98337d7c8757

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html