From 810a662abcd56509db2db3e385a6979a0d5cf021 Mon Sep 17 00:00:00 2001 From: Nicolai Buchwitz Date: Fri, 2 Oct 2026 11:42:09 +0200 Subject: [PATCH] net: reject a netdev that implements only one hwtstamp NDO ndo_hwtstamp_get and ndo_hwtstamp_set only make sense as a pair. A driver providing just one gets no complaint today, and the mismatch turns up in user space, where a set can succeed while the matching get fails. Catch it at registration instead. Suggested-by: Jakub Kicinski Signed-off-by: Nicolai Buchwitz Link: https://patch.msgid.link/20261002094211.2350702-4-nb@tipi-net.de Signed-off-by: Jakub Kicinski --- net/core/dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index ca7f4844cc40..db765cb5811e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11462,6 +11462,11 @@ static int netdev_check_ops(struct net_device *dev) return -EINVAL; } + if (!ops->ndo_hwtstamp_get != !ops->ndo_hwtstamp_set) { + netdev_WARN(dev, "driver implements only one hwtstamp NDO\n"); + return -EINVAL; + } + if (netdev_need_ops_lock(dev) && ops->ndo_set_rx_mode && !ops->ndo_set_rx_mode_async) { netdev_WARN(dev, "ops-locked drivers should use ndo_set_rx_mode_async\n");