ptp: Add error handling for adjfine callback in ptp_clock_adjtime
Subsystems (3)
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.
--- drivers/ptp/ptp_clock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ptp/ptp_clock.c +2 -1
@@ -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
Quoted 8 lines · Ajay Kaher
ptp_clock_adjtimesetsptp->dialed_frequencyeven when adjfine callback returns an error. This causes subsequent reads to return an incorrect value.Fix this by adding error check before
ptp->dialed_frequencyis set.Fixes 39a8cbd9ca05 ("ptp: remember the adjusted frequency")Signed-off-by Ajay Kaher <[email protected]>
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_adjtimesetsptp->dialed_frequencyeven when adjfine callback returns an error. This causes subsequent reads to return an incorrect value.Fix this by adding error check before
ptp->dialed_frequencyis set.Fixes 39a8cbd9ca05 ("ptp: remember the adjusted frequency")Signed-off-by Ajay Kaher <[email protected]>[...]
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