function_hooks: do the fake parameter assignment after parsing PARAM_LIMIT
commit53d4e2b6a8d0b7d844a80b7fec20c54b36fe440b
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 20 Sep 2018 12:08:07 +0000 (20 15:08 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 20 Sep 2018 12:08:07 +0000 (20 15:08 +0300)
tree0d4469fbed9081c514ce4fc5618fcc649d1eb19e
parent4152f4684c2a1370a72c3a10ca67173fe8936893
function_hooks: do the fake parameter assignment after parsing PARAM_LIMIT

This was leading to false positive warnings about "we previously assumed
'ptr' could be NULL".  The situation is, say a function returns
"s64min-s64max[$0->foo]", then when we hit an INTERNAL record, which is
the first thing we hit for a return, then we have an assignment.  The
problem is that the next thing we hit is maybe a PARAM_LIMIT which says
that $0 is non-NULL.  So since we haven't processed the PARAM_LIMIT we
think maybe $0 is a potential NULL dereference.

The solution is to do the fake assignment last.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_function_hooks.c