refcount: partial increments count as increments
commit8bce5f013978473a2e98402dd76ba8308f09cf7b
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 6 Oct 2023 09:28:55 +0000 (6 12:28 +0300)
committerDan Carpenter <dan.carpenter@linaro.org>
Fri, 6 Oct 2023 09:28:55 +0000 (6 12:28 +0300)
tree0aa89095dc9cae3ac9c90af0c60185351283af80
parent3e5533561987236da0158b631ac027a462a789c7
refcount: partial increments count as increments

This was_inced() function is used to detect frees vs non-frees.  If we
decrement a refcounted variable and we bumped the refcount then call free
it doesn't actually free it, it just decrements the refcount.  But if we
didn't increment it then it is a free.

So what about if it's both incremented and not-incremented?  Better to
treat it as incremented to avoid false positives and because something
complicated is probably happening.  For example, if a pointer was passed
in then we increment it but otherwise we allocate our own.  At the end we
decrement the passed in pointer or we free our pointer.  In the original
code we recorded that this function frees the parameter which is not
correct.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
smatch_refcount.c