diff options
author | Matthew Auld <[email protected]> | 2023-05-19 10:07:33 +0100 |
---|---|---|
committer | Thomas Zimmermann <[email protected]> | 2023-05-22 12:23:50 +0200 |
commit | c21f11d182c2180d8b90eaff84f574cfa845b250 (patch) | |
tree | 2e2e2b2a4493becaa5c557d4ba7b15875acbbc1c /lib/test_fortify/write_overflow-strlcpy-src.c | |
parent | aa8bf93101a185b49f83c9137453571a08be6e76 (diff) |
drm: fix drmm_mutex_init()
In mutex_init() lockdep identifies a lock by defining a special static
key for each lock class. However if we wrap the macro in a function,
like in drmm_mutex_init(), we end up generating:
int drmm_mutex_init(struct drm_device *dev, struct mutex *lock)
{
static struct lock_class_key __key;
__mutex_init((lock), "lock", &__key);
....
}
The static __key here is what lockdep uses to identify the lock class,
however since this is just a normal function the key here will be
created once, where all callers then use the same key. In effect the
mutex->depmap.key will be the same pointer for different
drmm_mutex_init() callers. This then results in impossible lockdep
splats since lockdep thinks completely unrelated locks are the same lock
class.
To fix this turn drmm_mutex_init() into a macro such that it generates a
different "static struct lock_class_key __key" for each invocation,
which looks to be inline with what mutex_init() wants.
v2:
- Revamp the commit message with clearer explanation of the issue.
- Rather export __drmm_mutex_release() than static inline.
Reported-by: Thomas Hellström <[email protected]>
Reported-by: Sarah Walker <[email protected]>
Fixes: e13f13e039dc ("drm: Add DRM-managed mutex_init()")
Cc: Stanislaw Gruszka <[email protected]>
Cc: Boris Brezillon <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: Jocelyn Falempe <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: [email protected]
Signed-off-by: Matthew Auld <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
Reviewed-by: Stanislaw Gruszka <[email protected]>
Reviewed-by: Lucas De Marchi <[email protected]>
Acked-by: Thomas Zimmermann <[email protected]>
Signed-off-by: Thomas Zimmermann <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Diffstat (limited to 'lib/test_fortify/write_overflow-strlcpy-src.c')
0 files changed, 0 insertions, 0 deletions