diff mbox series

[net-next,v2,2/2] netdevice: add DEFINE_FREE() for dev_put

Message ID 20240328082748.4f7e1895ed81.I1515fdc09a9f39fdbc26558556dd65a2cb03576a@changeid (mailing list archive)
State Accepted
Commit b1f81b9a535b48b2c9ca460720a2bc73fd2001de
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2,1/2] rtnetlink: add guard for RTNL | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4891 this patch: 4891
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: edumazet@google.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 1058 this patch: 1058
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api warning Found: 'dev_put(' was: 0 now: 1
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 5169 this patch: 5169
netdev/checkpatch warning WARNING: suspect code indent for conditional statements (0, 0)
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-31--03-00 (tests: 953)

Commit Message

Johannes Berg March 28, 2024, 7:27 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

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>
---
v2: resend
---
 include/linux/netdevice.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Simon Horman April 2, 2024, 8:28 a.m. UTC | #1
On Thu, Mar 28, 2024 at 08:27:50AM +0100, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> 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>
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cb37817d6382..f6c0d731fa35 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4127,6 +4127,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,