Thread (3 messages) 3 messages, 3 authors, 16d ago

Re: [PATCH] ethtool: tsinfo: release net_device reference in ethnl_tsinfo_start()

flat view

From: Jakub Kicinski <kuba@kernel.org>
Date: 2026-09-24 16:07:16
Also in: lkml
Subsystem: networking [ethtool], networking [general], the rest · Maintainers: Andrew Lunn, Jakub Kicinski, "David S. Miller", Eric Dumazet, Paolo Abeni, Linus Torvalds

On Sat, 19 Sep 2026 20:48:03 +0000 Hui Peng wrote:
quoted hunk ↗ jump to hunk
-	if (ctx->req_info->base.dev) {
-		struct net_device *dev = ctx->req_info->base.dev;
+	if (ctx->single_dev) {
+		struct net_device *dev = dev_get_by_index(net, ctx->pos_ifindex);
 
+		if (!dev)
+			return -ENODEV;
 		netdev_lock_ops_compat(dev);
 		ret = ethnl_tsinfo_dump_one_net_topo(skb, dev, cb);
 		netdev_unlock_ops_compat(dev);
+		dev_put(dev);
 		return ret;
This issue gotta be theoretical, can you build a repro that actually
triggers multi-skb dump for a single netdev? We don't have that much
info, it's gonna fit.

If you can trigger pls update the commit msg, if you can't let's instead
make this "official" by adding:
diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
index c9b680a9cc3f..cbb5d6b7f3e3 100644
--- a/net/ethtool/tsinfo.c
+++ b/net/ethtool/tsinfo.c
@@ -482,6 +482,7 @@ int ethnl_tsinfo_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
                netdev_lock_ops_compat(dev);
                ret = ethnl_tsinfo_dump_one_net_topo(skb, dev, cb);
                netdev_unlock_ops_compat(dev);
+               /* We don't want to hold the device ref across messages */
+               WARN_ON_ONCE(ret == -EMSGSIZE);
                return ret;
        }
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help