* [PATCH net v2] net: ethernet: xscale: Check for PTP support properly
@ 2026-02-11 12:58 Linus Walleij
2026-02-11 15:43 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2026-02-11 12:58 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Richard Cochran, Vadim Fedorenko, Vladimir Oltean
Cc: netdev, Linus Walleij
In ixp4xx_get_ts_info() ixp46x_ptp_find() is called
unconditionally despite this feature only existing on
ixp46x, leading to the following splat from tcpdump:
root@OpenWrt:~# tcpdump -vv -X -i eth0
(...)
Unable to handle kernel NULL pointer dereference at virtual address
00000238 when read
(...)
Call trace:
ptp_clock_index from ixp46x_ptp_find+0x1c/0x38
ixp46x_ptp_find from ixp4xx_get_ts_info+0x4c/0x64
ixp4xx_get_ts_info from __ethtool_get_ts_info+0x90/0x108
__ethtool_get_ts_info from __dev_ethtool+0xa00/0x2648
__dev_ethtool from dev_ethtool+0x160/0x234
dev_ethtool from dev_ioctl+0x2cc/0x460
dev_ioctl from sock_ioctl+0x1ec/0x524
sock_ioctl from sys_ioctl+0x51c/0xa94
sys_ioctl from ret_fast_syscall+0x0/0x44
(...)
Segmentation fault
Check for ixp46x in ixp46x_ptp_find() before trying to set up
PTP to avoid this.
Fixes: 9055a2f59162 ("ixp4xx_eth: make ptp support a platform driver")
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
Changes in v2:
- Use the correct Fixes-tag.
- Move check to ixp46x_ptp_find() to simplify things.
- Link to v1: https://lore.kernel.org/r/20260116-ixp4xx-fix-ethernet-v1-1-9ab3b411c77e@kernel.org
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 5 +----
drivers/net/ethernet/xscale/ptp_ixp46x.c | 3 +++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index e1e7f65553e7..b0faa0f1780d 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -403,15 +403,12 @@ static int ixp4xx_hwtstamp_set(struct net_device *netdev,
int ret;
int ch;
- if (!cpu_is_ixp46x())
- return -EOPNOTSUPP;
-
if (!netif_running(netdev))
return -EINVAL;
ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
if (ret)
- return ret;
+ return -EOPNOTSUPP;
ch = PORT2CHANNEL(port);
regs = port->timesync_regs;
diff --git a/drivers/net/ethernet/xscale/ptp_ixp46x.c b/drivers/net/ethernet/xscale/ptp_ixp46x.c
index 94203eb46e6b..93c64db22a69 100644
--- a/drivers/net/ethernet/xscale/ptp_ixp46x.c
+++ b/drivers/net/ethernet/xscale/ptp_ixp46x.c
@@ -232,6 +232,9 @@ static struct ixp_clock ixp_clock;
int ixp46x_ptp_find(struct ixp46x_ts_regs *__iomem *regs, int *phc_index)
{
+ if (!cpu_is_ixp46x())
+ return -ENODEV;
+
*regs = ixp_clock.regs;
*phc_index = ptp_clock_index(ixp_clock.ptp_clock);
---
base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260116-ixp4xx-fix-ethernet-4fa36d900ccc
Best regards,
--
Linus Walleij <linusw@kernel.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] net: ethernet: xscale: Check for PTP support properly
2026-02-11 12:58 [PATCH net v2] net: ethernet: xscale: Check for PTP support properly Linus Walleij
@ 2026-02-11 15:43 ` Andrew Lunn
2026-02-11 21:03 ` Linus Walleij
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2026-02-11 15:43 UTC (permalink / raw)
To: Linus Walleij
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Richard Cochran, Vadim Fedorenko, Vladimir Oltean,
netdev
On Wed, Feb 11, 2026 at 01:58:21PM +0100, Linus Walleij wrote:
> In ixp4xx_get_ts_info() ixp46x_ptp_find() is called
> unconditionally despite this feature only existing on
> ixp46x, leading to the following splat from tcpdump:
>
> root@OpenWrt:~# tcpdump -vv -X -i eth0
> (...)
> Unable to handle kernel NULL pointer dereference at virtual address
> 00000238 when read
> (...)
> Call trace:
> ptp_clock_index from ixp46x_ptp_find+0x1c/0x38
> ixp46x_ptp_find from ixp4xx_get_ts_info+0x4c/0x64
> ixp4xx_get_ts_info from __ethtool_get_ts_info+0x90/0x108
> __ethtool_get_ts_info from __dev_ethtool+0xa00/0x2648
> __dev_ethtool from dev_ethtool+0x160/0x234
> dev_ethtool from dev_ioctl+0x2cc/0x460
> dev_ioctl from sock_ioctl+0x1ec/0x524
> sock_ioctl from sys_ioctl+0x51c/0xa94
> sys_ioctl from ret_fast_syscall+0x0/0x44
> (...)
> Segmentation fault
>
> Check for ixp46x in ixp46x_ptp_find() before trying to set up
> PTP to avoid this.
> ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
> if (ret)
> - return ret;
> + return -EOPNOTSUPP;
Changing the error code is unusual. Maybe add to the commit message
why this is needed, or somebody might ask :-)
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] net: ethernet: xscale: Check for PTP support properly
2026-02-11 15:43 ` Andrew Lunn
@ 2026-02-11 21:03 ` Linus Walleij
2026-02-12 23:06 ` Jacob Keller
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2026-02-11 21:03 UTC (permalink / raw)
To: Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Richard Cochran, Vadim Fedorenko, Vladimir Oltean,
netdev
On Wed, Feb 11, 2026 at 4:43 PM Andrew Lunn <andrew@lunn.ch> wrote:
> On Wed, Feb 11, 2026 at 01:58:21PM +0100, Linus Walleij wrote:
> > In ixp4xx_get_ts_info() ixp46x_ptp_find() is called
> > unconditionally despite this feature only existing on
> > ixp46x, leading to the following splat from tcpdump:
> >
> > root@OpenWrt:~# tcpdump -vv -X -i eth0
> > (...)
> > Unable to handle kernel NULL pointer dereference at virtual address
> > 00000238 when read
> > (...)
> > Call trace:
> > ptp_clock_index from ixp46x_ptp_find+0x1c/0x38
> > ixp46x_ptp_find from ixp4xx_get_ts_info+0x4c/0x64
> > ixp4xx_get_ts_info from __ethtool_get_ts_info+0x90/0x108
> > __ethtool_get_ts_info from __dev_ethtool+0xa00/0x2648
> > __dev_ethtool from dev_ethtool+0x160/0x234
> > dev_ethtool from dev_ioctl+0x2cc/0x460
> > dev_ioctl from sock_ioctl+0x1ec/0x524
> > sock_ioctl from sys_ioctl+0x51c/0xa94
> > sys_ioctl from ret_fast_syscall+0x0/0x44
> > (...)
> > Segmentation fault
> >
> > Check for ixp46x in ixp46x_ptp_find() before trying to set up
> > PTP to avoid this.
>
> > ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
> > if (ret)
> > - return ret;
> > + return -EOPNOTSUPP;
>
> Changing the error code is unusual. Maybe add to the commit message
> why this is needed, or somebody might ask :-)
Tricky one, but if you look close changing the error code is what I
try not to do! :D
Before this patch ixp4xx_hwtstamp_set() returned -EOPNOTSUPP:
- if (!cpu_is_ixp46x())
- return -EOPNOTSUPP;
After moving the check into ixp46x_ptp_find() as requested in the
review of v1 I have to return some error code from that new check,
but it is now called from more places, so it returns
int ixp46x_ptp_find(struct ixp46x_ts_regs *__iomem *regs, int *phc_index)
{
+ if (!cpu_is_ixp46x())
+ return -ENODEV;
So this:
ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
if (ret)
- return ret;
+ return -EOPNOTSUPP;
Is put into ixp4xx_hwtstamp_set() so it will return the same error
code as before if PTP was not found.
(I can copyedit this reasoning into the commit message if you want.)
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] net: ethernet: xscale: Check for PTP support properly
2026-02-11 21:03 ` Linus Walleij
@ 2026-02-12 23:06 ` Jacob Keller
0 siblings, 0 replies; 4+ messages in thread
From: Jacob Keller @ 2026-02-12 23:06 UTC (permalink / raw)
To: Linus Walleij, Andrew Lunn
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Richard Cochran, Vadim Fedorenko, Vladimir Oltean,
netdev
On 2/11/2026 1:03 PM, Linus Walleij wrote:
> On Wed, Feb 11, 2026 at 4:43 PM Andrew Lunn <andrew@lunn.ch> wrote:
>> On Wed, Feb 11, 2026 at 01:58:21PM +0100, Linus Walleij wrote:
>>> In ixp4xx_get_ts_info() ixp46x_ptp_find() is called
>>> unconditionally despite this feature only existing on
>>> ixp46x, leading to the following splat from tcpdump:
>>>
>>> root@OpenWrt:~# tcpdump -vv -X -i eth0
>>> (...)
>>> Unable to handle kernel NULL pointer dereference at virtual address
>>> 00000238 when read
>>> (...)
>>> Call trace:
>>> ptp_clock_index from ixp46x_ptp_find+0x1c/0x38
>>> ixp46x_ptp_find from ixp4xx_get_ts_info+0x4c/0x64
>>> ixp4xx_get_ts_info from __ethtool_get_ts_info+0x90/0x108
>>> __ethtool_get_ts_info from __dev_ethtool+0xa00/0x2648
>>> __dev_ethtool from dev_ethtool+0x160/0x234
>>> dev_ethtool from dev_ioctl+0x2cc/0x460
>>> dev_ioctl from sock_ioctl+0x1ec/0x524
>>> sock_ioctl from sys_ioctl+0x51c/0xa94
>>> sys_ioctl from ret_fast_syscall+0x0/0x44
>>> (...)
>>> Segmentation fault
>>>
>>> Check for ixp46x in ixp46x_ptp_find() before trying to set up
>>> PTP to avoid this.
>>
>>> ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
>>> if (ret)
>>> - return ret;
>>> + return -EOPNOTSUPP;
>>
>> Changing the error code is unusual. Maybe add to the commit message
>> why this is needed, or somebody might ask :-)
>
> Tricky one, but if you look close changing the error code is what I
> try not to do! :D
>
> Before this patch ixp4xx_hwtstamp_set() returned -EOPNOTSUPP:
>
> - if (!cpu_is_ixp46x())
> - return -EOPNOTSUPP;
>
> After moving the check into ixp46x_ptp_find() as requested in the
> review of v1 I have to return some error code from that new check,
> but it is now called from more places, so it returns
>
> int ixp46x_ptp_find(struct ixp46x_ts_regs *__iomem *regs, int *phc_index)
> {
> + if (!cpu_is_ixp46x())
> + return -ENODEV;
>
> So this:
>
> ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
> if (ret)
> - return ret;
> + return -EOPNOTSUPP;
>
> Is put into ixp4xx_hwtstamp_set() so it will return the same error
> code as before if PTP was not found.
>
> (I can copyedit this reasoning into the commit message if you want.)
>
> Yours,
> Linus Walleij
>
That would be helpful to have in the commit message, since it is not
immediately obvious.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-12 23:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 12:58 [PATCH net v2] net: ethernet: xscale: Check for PTP support properly Linus Walleij
2026-02-11 15:43 ` Andrew Lunn
2026-02-11 21:03 ` Linus Walleij
2026-02-12 23:06 ` Jacob Keller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox