Re: [v6] coccinelle: semantic code search for missing put_device()
From: Markus Elfring
Date: Sun Feb 17 2019 - 08:15:04 EST
>> +@search exists@
>> +local idexpression id;
>> +expression x,e,e1;
>> +position p1,p2;
>> +id = of_find_device_by_node@p1(x)
>> +... when != e = id
>> + ... when != id = e
>> Which SmPL specification will achieve the desired software behaviour?
> The desired behavior is to check whether the allocated value is saved in
> some other variable (typically a structure field) and thus it doesn't need
> to be freed just because the original local variable goes out of scope at
> the end of the function.
I find this description reasonable to some degree.
(I am unsure if a programmer would like to fiddle with return value storage
in a data structure member from a local variable.)
> when != e = id achieves this behavior.
I can not agree to this view completely because of the meaning that is connected
with these variable identifiers.
Both metavariables share the kind âexpressionâ. So I can imagine
that there is an intersection for the source code match possibility.
But one was intentionally restricted to the kind âlocal idexpressionâ so far.
Which data element should not get reassigned here (before a corresponding
null pointer check)?