Re: [PATCH net-next v2] net: hold netdev reference during qdisc_create request_module
From: Jakub Kicinski
Date: Mon Mar 24 2025 - 18:08:53 EST
On Thu, 20 Mar 2025 09:51:03 -0700 Stanislav Fomichev wrote:
> rtnl_lock();
> netdev_lock_ops(dev);
> + dev_put(dev);
> ops = qdisc_lookup_ops(kind);
I'm not sure if this is a correct sequence. Do we guarantee that locks
will be taken before device is freed? I mean we do:
dev = netdev_wait_allrefs_any()
free_netdev(dev)
mutex_destroy(dev->lock)
without explicitly taking rtnl_lock() or netdev_lock(), so the moment
that dev_put() is called the device may get freed from another thread
- while its locked here.
My mental model is that taking the instance lock on a dev for which we
only have a ref requires a dance implemented in __netdev_put_lock().