netdevice: add DEFINE_FREE() for dev_put
authorJohannes Berg <johannes.berg@intel.com>
Thu, 28 Mar 2024 07:27:50 +0000 (08:27 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Apr 2024 08:59:38 +0000 (09:59 +0100)
For short netdev holds within a function there are still a lot of
users of dev_put() rather than netdev_put(). Add DEFINE_FREE() to
allow making those safer.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h

index 7d12b5a9380f4f04c7d798e96b96d159dbf98d5f..0c198620ac93e03d811e4f734c779c8bce6e8203 100644 (file)
@@ -4097,6 +4097,8 @@ static inline void dev_put(struct net_device *dev)
        netdev_put(dev, NULL);
 }
 
+DEFINE_FREE(dev_put, struct net_device *, if (_T) dev_put(_T))
+
 static inline void netdev_ref_replace(struct net_device *odev,
                                      struct net_device *ndev,
                                      netdevice_tracker *tracker,