[cfe-dev] malloc checker and kmalloc

Balázs Kéri via cfe-dev cfe-dev at lists.llvm.org
Tue Feb 18 08:56:58 PST 2020

I found a problematic case with the MallocChecker. The checker does not
handle the malloc functions if it is inlined. In Linux kernel source code
the "kmalloc" function seems to be inlined and it returns with a fixed
value ((void*)16) ("ZERO_SIZE_PTR") (for my case at least) if a zero-sized
block is allocated. When later this block is freed (with "kfree") a warning
is reported about freeing of a constant address. In this case it is a false
positive because the special value is allowed to be freed.
The problem is probably not easy to fix, specially allow to free a fixed
value if it is the result of a (probably inlined) malloc call?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200218/65f7a35b/attachment.html>

More information about the cfe-dev mailing list