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

include/linux/kref.h: can't annotate kref_put_lock #138

Open himanshujha199640 opened 5 years ago

himanshujha199640 commented 5 years ago

https://elixir.bootlin.com/linux/v5.2-rc2/source/include/linux/kref.h#L84

/home/himanshu/clang-thread-safety-analysis/include/linux/kref.h:93:1: warning: mutex 'lock' is not held on every path through here [-Wthread-safety-analysis]
}
^
/home/himanshu/clang-thread-safety-analysis/include/linux/kref.h:88:6: note: mutex acquired here
        if (refcount_dec_and_lock(&kref->refcount, lock)) {
            ^

release is a pointer to the function that will clean up the object when the last reference to the object is released. There is no way better way here to let analysis know that release will do the spin_unlock. Users: https://elixir.bootlin.com/linux/v5.2-rc2/source/net/sunrpc/svcauth.c#L158