mirror of
https://github.com/torvalds/linux.git
synced 2026-11-29 01:43:18 +00:00
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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Harshitha Ramamurthy <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Signed-off-by: Tim Hostetler <[email protected]> Acked-by: Richard Cochran <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
committed by
Jakub Kicinski
parent
89aec171d9
commit
dfb073d32c
@@ -322,7 +322,9 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
|
||||
char debugfsname[16];
|
||||
size_t size;
|
||||
|
||||
if (info->n_alarm > PTP_MAX_ALARMS)
|
||||
if (WARN_ON_ONCE(info->n_alarm > PTP_MAX_ALARMS ||
|
||||
(!info->gettimex64 && !info->gettime64) ||
|
||||
!info->settime64))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
/* Initialize a clock structure. */
|
||||
|
||||
Reference in New Issue
Block a user