[PATCH net v2 1/2] net: ethtool: don't match a hwtstamp provider on a device without a PHC

From: Nicolai Buchwitz

Date: Wed Sep 23 2026 - 08:32:27 EST


A device without a PHC reports phc_index -1. A request for index
0xFFFFFFFF is stored in an int and becomes -1 too, so the two match and
a netdev provider is selected on a device that has none.

Fix this and only match a real PHC index.

Fixes: b9e3f7dc9ed9 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology")
Signed-off-by: Nicolai Buchwitz <nb@xxxxxxxxxxx>
---
net/ethtool/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 23db40618fed..23e8282563cc 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -980,7 +980,7 @@ int ethtool_net_get_ts_info_by_phc(struct net_device *dev,
if (err)
return err;

- if (info->phc_index == hwprov_desc->index &&
+ if (info->phc_index >= 0 && info->phc_index == hwprov_desc->index &&
net_support_hwtstamp_qualifier(dev, hwprov_desc->qualifier))
return 0;

--
2.53.0