Skip to content

Commit b4e1661

Browse files
committed
genetlink: Add rcu_dereference_genl and genl_dereference.
This adds rcu_dereference_genl and genl_dereference, which are genl variants of the RTNL functions to enforce proper locking with lockdep and sparse. Signed-off-by: Jesse Gross <[email protected]>
1 parent 86b1309 commit b4e1661

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

include/linux/genetlink.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,27 @@ extern void genl_unlock(void);
8989
extern int lockdep_genl_is_held(void);
9090
#endif
9191

92+
/**
93+
* rcu_dereference_genl - rcu_dereference with debug checking
94+
* @p: The pointer to read, prior to dereferencing
95+
*
96+
* Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
97+
* or genl mutex. Note : Please prefer genl_dereference() or rcu_dereference()
98+
*/
99+
#define rcu_dereference_genl(p) \
100+
rcu_dereference_check(p, lockdep_genl_is_held())
101+
102+
/**
103+
* genl_dereference - fetch RCU pointer when updates are prevented by genl mutex
104+
* @p: The pointer to read, prior to dereferencing
105+
*
106+
* Return the value of the specified RCU-protected pointer, but omit
107+
* both the smp_read_barrier_depends() and the ACCESS_ONCE(), because
108+
* caller holds genl mutex.
109+
*/
110+
#define genl_dereference(p) \
111+
rcu_dereference_protected(p, lockdep_genl_is_held())
112+
92113
#endif /* __KERNEL__ */
93114

94115
#endif /* __LINUX_GENERIC_NETLINK_H */

0 commit comments

Comments
 (0)