Syzbot reports a NULL function pointer call on arm64 when ptp_clock_gettime() falls back to ->gettime64() and the driver provides neither ->gettimex64() nor ->gettime64(). This leads to a crash in the posix clock gettime path. Return -EOPNOTSUPP when both callbacks are missing, avoiding the crash and matching the defensive style used in the posix clock layer. Reported-by: syzbot+c8c0e7ccabd456541612@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=c8c0e7ccabd456541612 Signed-off-by: Junjie Cao --- drivers/ptp/ptp_clock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions( diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index ef020599b771..764bd25220c1 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -110,12 +110,14 @@ static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 *tp static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp) { struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); - int err; + int err = -EOPNOTSUPP; if (ptp->info->gettimex64) - err = ptp->info->gettimex64(ptp->info, tp, NULL); - else - err = ptp->info->gettime64(ptp->info, tp); + return ptp->info->gettimex64(ptp->info, tp, NULL); + + if (ptp->info->gettime64) + return ptp->info->gettime64(ptp->info, tp); + return err; } -- 2.43.0