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

net/sched/cls_api.c: _tcf_block_put: broken __try_acquires? #120

Open bulwahn opened 5 years ago

bulwahn commented 5 years ago
net/sched/cls_api.c:1270:3: warning: releasing mutex 'block->lock' that was not held [-Wthread-safety-analysis]
                mutex_unlock(&block->lock);
                ^
net/sched/cls_api.c:1284:1: warning: mutex 'block->lock' is not held on every path through here [-Wthread-safety-analysis]
}
^
net/sched/cls_api.c:1261:6: note: mutex acquired here
        if (refcount_dec_and_mutex_lock(&block->refcnt, &block->lock)) {
            ^
2 warnings generated.

_tcf_block_put first tries to obtain the lock with refcount_dec_and_mutex_lock, which is annotated with __try_acquires_mutex(true, lock), and then unlocks this mutex later on, or it does not get the lock and does nothing further with the lock.

This might need a small example to see if clang thread safety analysis is just broken here.