Skip to content

Commit 594163e

Browse files
linuswkuba-moo
authored andcommitted
net: ethernet: xscale: Check for PTP support properly
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. To avoid altering the returned error code from ixp4xx_hwtstamp_set() which before this patch was -EOPNOTSUPP, we return -EOPNOTSUPP from ixp4xx_hwtstamp_set() if ixp46x_ptp_find() fails no matter the error code. The helper function ixp46x_ptp_find() helper returns -ENODEV. Fixes: 9055a2f ("ixp4xx_eth: make ptp support a platform driver") Signed-off-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20260219-ixp4xx-fix-ethernet-v3-1-f235ccc3cd46@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2bb995e commit 594163e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/net/ethernet/xscale/ixp4xx_eth.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,12 @@ static int ixp4xx_hwtstamp_set(struct net_device *netdev,
403403
int ret;
404404
int ch;
405405

406-
if (!cpu_is_ixp46x())
407-
return -EOPNOTSUPP;
408-
409406
if (!netif_running(netdev))
410407
return -EINVAL;
411408

412409
ret = ixp46x_ptp_find(&port->timesync_regs, &port->phc_index);
413410
if (ret)
414-
return ret;
411+
return -EOPNOTSUPP;
415412

416413
ch = PORT2CHANNEL(port);
417414
regs = port->timesync_regs;

drivers/net/ethernet/xscale/ptp_ixp46x.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ static struct ixp_clock ixp_clock;
232232

233233
int ixp46x_ptp_find(struct ixp46x_ts_regs *__iomem *regs, int *phc_index)
234234
{
235+
if (!cpu_is_ixp46x())
236+
return -ENODEV;
237+
235238
*regs = ixp_clock.regs;
236239
*phc_index = ptp_clock_index(ixp_clock.ptp_clock);
237240

0 commit comments

Comments
 (0)