iavf: add missing PTP adjustment callbacks
Subsystems (4)
PATCH 1/1 iavf: add missing PTP adjustment callbacks
From: Xuanqiang Luo <[email protected]>
The PTP hardware clock documentation requires drivers to implement all callbacks and return -EOPNOTSUPP for unsupported features.
The iavf driver registers a PHC without adjtime or adjfine callbacks. A userspace clock_adjtime(2) request reaches ptp_clock_adjtime(), where ADJ_SETOFFSET calls adjtime and ADJ_FREQUENCY calls adjfine. The missing callbacks can therefore cause a NULL dereference.
Provide both callbacks and return -EOPNOTSUPP for the unsupported operations.
--- drivers/net/ethernet/intel/iavf/iavf_ptp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_ptp.c +12 -0
@@ -252,6 +252,16 @@ static int iavf_ptp_gettimex64(struct ptp_clock_info *info,return iavf_read_phc_indirect (adapter, ts, sts); } +static int iavf_ptp_adjfine (struct ptp_clock_info *info,long scaled_ppm) +{ +return -EOPNOTSUPP ; +} + +static int iavf_ptp_adjtime (struct ptp_clock_info *info,s64 delta) +{ +return -EOPNOTSUPP ; +} +static int iavf_ptp_settime64 (struct ptp_clock_info *info,const struct timespec64 *ts) {
@@ -326,6 +336,8 @@ static int iavf_ptp_register_clock(struct iavf_adapter *adapter) KBUILD_MODNAME, dev_name(dev)); ptp_info->owner =THIS_MODULE ; ptp_info->gettimex64 = iavf_ptp_gettimex64; + ptp_info->adjfine = iavf_ptp_adjfine; + ptp_info->adjtime = iavf_ptp_adjtime; ptp_info->settime64 = iavf_ptp_settime64; ptp_info->do_aux_work = iavf_ptp_do_aux_work;
Signature · 1 line
2.43.0
Quoted 44 lines · Xuanqiang Luo
From: Xuanqiang Luo <[email protected]>
The PTP hardware clock documentation requires drivers to implement all callbacks and return
-EOPNOTSUPPfor unsupported features.The iavf driver registers a PHC without adjtime or adjfine callbacks. A userspace
clock_adjtime(2)request reachesptp_clock_adjtime(), whereADJ_SETOFFSETcalls adjtime andADJ_FREQUENCYcalls adjfine. The missing callbacks can therefore cause a NULL dereference.Provide both callbacks and return
-EOPNOTSUPPfor the unsupported operations.Fixes d734223b2f0d ("iavf: add initial framework for registering PTP clock")Signed-off-by Xuanqiang Luo <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_ptp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/net/ethernet/intel/iavf/iavf_ptp.c +10
-0@@ -252,6 +252,16 @@ static int iavf_ptp_gettimex64(struct ptp_clock_info *info,return iavf_read_phc_indirect (adapter, ts, sts); } +static int iavf_ptp_adjfine (struct ptp_clock_info *info,long scaled_ppm) +{ +return -EOPNOTSUPP ; +} + +static int iavf_ptp_adjtime (struct ptp_clock_info *info,s64 delta) +{ +return -EOPNOTSUPP ; +} +static int iavf_ptp_settime64 (struct ptp_clock_info *info,const struct timespec64 *ts) {
drivers/net/ethernet/intel/iavf/iavf_ptp.c static int iavf_ptp_register_clock(struct iavf_adapter *adapter) · line 343
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_ptp.c +2
-0@@ -326,6 +336,8 @@ static int iavf_ptp_register_clock(struct iavf_adapter *adapter) KBUILD_MODNAME, dev_name(dev)); ptp_info->owner =THIS_MODULE ; ptp_info->gettimex64 = iavf_ptp_gettimex64; + ptp_info->adjfine = iavf_ptp_adjfine; + ptp_info->adjtime = iavf_ptp_adjtime; ptp_info->settime64 = iavf_ptp_settime64; ptp_info->do_aux_work = iavf_ptp_do_aux_work;
Jacob Keller
Acked-byQuoted 14 lines · Vadim Fedorenko
Quoted 13 lines · Xuanqiang Luo
From: Xuanqiang Luo <[email protected]>
The PTP hardware clock documentation requires drivers to implement all callbacks and return
-EOPNOTSUPPfor unsupported features.The iavf driver registers a PHC without adjtime or adjfine callbacks. A userspace
clock_adjtime(2)request reachesptp_clock_adjtime(), whereADJ_SETOFFSETcalls adjtime andADJ_FREQUENCYcalls adjfine. The missing callbacks can therefore cause a NULL dereference.Provide both callbacks and return
-EOPNOTSUPPfor the unsupported operations.
Quoted 7 lines
Quoted 7 lines
Fixes d734223b2f0d ("iavf: add initial framework for registering PTPclock")
Signed-off-by Xuanqiang Luo <[email protected]>
Quoted 38 lines
Quoted 36 lines
---
drivers/net/ethernet/intel/iavf/iavf_ptp.c| 12 ++++++++++++1 file changed, 12 insertions(+)drivers/net/ renamed from drivers/net/ethernet/intel/iavf/iavf_ptp.c +0
-0
ethernet/intel/iavf/iavf_ptp.c
index87b97e09df14a..fcb273828bc1b100644drivers/net/ethernet/intel/iavf/iavf_ptp.c +0
-0@@ -252,6 +252,16 @@ static int iavf_ptp_gettimex64(structptp_clock_info *info, return iavf_read_phc_indirect(adapter, ts, sts); }+static int
iavf_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)drivers/net/ethernet/intel/iavf/iavf_ptp.c +9
-0+{ + return -EOPNOTSUPP; +} + +static int iavf_ptp_adjtime (struct ptp_clock_info *info,s64 delta) +{ + return -EOPNOTSUPP; +} +static int
iavf_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
{drivers/net/ethernet/intel/iavf/iavf_ptp.c +2
-0@@ -326,6 +336,8 @@ static int iavf_ptp_register_clock(struct iavf_adapter *adapter) KBUILD_MODNAME, dev_name(dev)); ptp_info->owner = THIS_MODULE; ptp_info->gettimex64 = iavf_ptp_gettimex64; + ptp_info->adjfine = iavf_ptp_adjfine; + ptp_info->adjtime = iavf_ptp_adjtime; ptp_info->settime64 = iavf_ptp_settime64; ptp_info->do_aux_work = iavf_ptp_do_aux_work;Quoted 1 line
Reviewed-by Vadim Fedorenko <[email protected]>
Romanowski, Rafal
Tested-byQuoted 38 lines
-----Original Message-----
From: Jacob Keller <[email protected]>
Sent: Monday, August 31, 2026 11:58 PM
To: Vadim Fedorenko <[email protected]>; Xuanqiang Luo <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Xuanqiang Luo <[email protected]>; [email protected]
Subject: Re: [PATCH net v1] iavf: add missing PTP adjustment callbacksQuoted 14 lines · Vadim Fedorenko
Quoted 13 lines · Xuanqiang Luo
From: Xuanqiang Luo <[email protected]>
The PTP hardware clock documentation requires drivers to implement all callbacks and return
-EOPNOTSUPPfor unsupported features.The iavf driver registers a PHC without adjtime or adjfine callbacks. A userspace
clock_adjtime(2)request reachesptp_clock_adjtime(), whereADJ_SETOFFSETcalls adjtime andADJ_FREQUENCYcalls adjfine. The missing callbacks can therefore cause a NULL dereference.Provide both callbacks and return
-EOPNOTSUPPfor the unsupported operations.Quoted 8 lines
Quoted 8 lines
Fixes d734223b2f0d ("iavf: add initial framework for registering PTPclock")
Link:
https://docs.kernel.org/driver-api/ptp.html#writing-clock-driversSigned-off-by Xuanqiang Luo <[email protected]>
Quoted 40 lines
Acked-by Jacob Keller <[email protected]>Quoted 38 lines
Quoted 29 lines
---
drivers/net/ethernet/intel/iavf/iavf_ptp.c| 12 ++++++++++++1 file changed, 12 insertions(+)(quoted diff) +0
-0b/drivers/net/
ethernet/intel/iavf/iavf_ptp.cindex87b97e09df14a..fcb273828bc1b100644drivers/net/ethernet/intel/iavf/iavf_ptp.c +0
-0@@ -252,6 +252,16 @@ static int iavf_ptp_gettimex64(structptp_clock_info *info, return iavf_read_phc_indirect(adapter, ts, sts); }+static int
iavf_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)drivers/net/ethernet/intel/iavf/iavf_ptp.c +9
-0+{ + return -EOPNOTSUPP; +} + +static int iavf_ptp_adjtime (struct ptp_clock_info *info,s64 delta) +{ + return -EOPNOTSUPP; +} +static int
iavf_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
{drivers/net/ethernet/intel/iavf/iavf_ptp.c static int iavf_ptp_register_clock(struct · line 343
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_ptp.c +2
-0@@ -326,6 +336,8 @@ static int iavf_ptp_register_clock(struct iavf_adapter *adapter) KBUILD_MODNAME, dev_name(dev)); ptp_info->owner = THIS_MODULE; ptp_info->gettimex64 = iavf_ptp_gettimex64; + ptp_info->adjfine = iavf_ptp_adjfine; + ptp_info->adjtime = iavf_ptp_adjtime; ptp_info->settime64 = iavf_ptp_settime64; ptp_info->do_aux_work = iavf_ptp_do_aux_work;Reviewed-by Vadim Fedorenko <[email protected]>