leaks: don't reset states to themselves
commit2dc325b88ccfaa20c3caa7c103bab9a6de79e146
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 25 Feb 2016 21:52:14 +0000 (26 00:52 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 25 Feb 2016 21:52:14 +0000 (26 00:52 +0300)
tree362f27be6898596cc146cb75b7b281f7d6c3a9de
parentcb6015ff209c7475afba716a42435aee7bf665eb
leaks: don't reset states to themselves

Take this sample code:

foo = kmalloc();  <- set state to &allocated here
if (!foo)
return -ENOMEM;  <- state should be &ok here
if (!bar)
return -EINVAL;  <- state should be &allocated here

So when we get to the condition "if (!foo) ", the most likely scenario is
that we start with &allocated.  In the original code, we set the true side
to &allocated (which it already was) and the false side to &ok (meaning
that it's ok to return here because it won't leak).

The problem is that setting it from &allocated to &allocated meant that we
screwed up the implications so when the implication code said "Have we
changed the state since our implication the answer was yes when really it
should have been no."  Then because implications weren't working correctly
it lead to false positives.

Reported-by: Amir Vadai <amir@vadai.me>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_leaks.c