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

From: Jakub Kicinski

Date: Thu Sep 24 2026 - 12:33:49 EST


On Sat, 19 Sep 2026 20:48:03 +0000 Hui Peng wrote:
> - 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;
}