Skip to content

Commit d7fe143

Browse files
botta633fbq
authored andcommitted
locking/lockdep: Avoid creating new name string literals in lockdep_set_subclass()
Syzbot reports a problem that a warning will be triggered while searching a lock class in look_up_lock_class(). The cause of the issue is that a new name is created and used by lockdep_set_subclass() instead of using the existing one. This results in a lock instance has a different name pointer than previous registered one stored in lock class, and WARN_ONCE() is triggered because of that in look_up_lock_class(). To fix this, change lockdep_set_subclass() to use the existing name instead of a new one. Hence, no new name will be created by lockdep_set_subclass(). Hence, the warning is avoided. [boqun: Reword the commit log to state the correct issue] Reported-by: <[email protected]> Fixes: de8f5e4 ("lockdep: Introduce wait-type checks") Cc: [email protected] Signed-off-by: Ahmed Ehab <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/
1 parent 0784181 commit d7fe143

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/lockdep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static inline void lockdep_init_map(struct lockdep_map *lock, const char *name,
173173
(lock)->dep_map.lock_type)
174174

175175
#define lockdep_set_subclass(lock, sub) \
176-
lockdep_init_map_type(&(lock)->dep_map, #lock, (lock)->dep_map.key, sub,\
176+
lockdep_init_map_type(&(lock)->dep_map, (lock)->dep_map.name, (lock)->dep_map.key, sub,\
177177
(lock)->dep_map.wait_type_inner, \
178178
(lock)->dep_map.wait_type_outer, \
179179
(lock)->dep_map.lock_type)

0 commit comments

Comments
 (0)