Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ptp: Return -EINVAL on ptp_clock_register if required ops are NULL

ptp_clock should never be registered unless it stubs one of gettimex64()
or gettime64() and settime64(). WARN_ON_ONCE and error out if either set
of function pointers is null.

For consistency, n_alarm validation is also folded into the
WARN_ON_ONCE.

Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Tim Hostetler <thostet@google.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://patch.msgid.link/20251104225915.2040080-1-thostet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Tim Hostetler and committed by
Jakub Kicinski
dfb073d3 89aec171

+3 -1
+3 -1
drivers/ptp/ptp_clock.c
··· 322 322 char debugfsname[16]; 323 323 size_t size; 324 324 325 - if (info->n_alarm > PTP_MAX_ALARMS) 325 + if (WARN_ON_ONCE(info->n_alarm > PTP_MAX_ALARMS || 326 + (!info->gettimex64 && !info->gettime64) || 327 + !info->settime64)) 326 328 return ERR_PTR(-EINVAL); 327 329 328 330 /* Initialize a clock structure. */