ClangBuiltLinux / thread-safety-analysis

A research project into applying Clang's Thread Safety Analysis to the Linux Kernel
Other
6 stars 0 forks source link

drivers/gpu/drm/i915/i915_gem_shrinker.c: shrinker_{lock,unlock}: complex locking/unlocking functions #164

Open bulwahn opened 4 years ago

bulwahn commented 4 years ago
drivers/gpu/drm/i915/i915_gem_shrinker.c:54:11: warning: mutex 'm' is not held on every path through here [-Wthread-safety-analysis]
                return *unlock;
                        ^
drivers/gpu/drm/i915/i915_gem_shrinker.c:52:7: note: mutex acquired here
                    mutex_lock_killable_nested(m, I915_MM_SHRINKER) == 0)
                    ^
./include/linux/mutex.h:185:53: note: expanded from macro 'mutex_lock_killable_nested'
# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock)
                                                    ^

drivers/gpu/drm/i915/i915_gem_shrinker.c:69:2: warning: releasing mutex 'i915->drm.struct_mutex' that was not held [-Wthread-safety-analysis]
        mutex_unlock(&i915->drm.struct_mutex);
        ^

shrinker_lock cannot be handled due to aliasing and complex locking functions. Further it returns a boolean return value to indicate to unlock if it needs unlocking. shrinker_unlock conditionally unlocks based on the provided boolean.