[Intel-gfx] [PATCH 1/7] device: prevent a NULL pointer dereference in __intel_peek_fd

Martin Peres martin.peres at linux.intel.com
Mon Feb 15 15:56:02 UTC 2016


On 15/02/16 15:47, Dave Gordon wrote:
> On 15/02/16 13:40, Martin Peres wrote:
>> On 15/02/16 14:24, Dave Gordon wrote:
>>> On 12/02/16 16:31, Martin Peres wrote:
>>>> This is not a big issue to return -1 since the only codepath that uses
>>>> it is for display purposes.
>>>>
>>>> Caught by Klockwork.
>>>>
>>>> Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
>>>> ---
>>>>   src/intel_device.c | 5 ++++-
>>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/intel_device.c b/src/intel_device.c
>>>> index 54c1443..35e652a 100644
>>>> --- a/src/intel_device.c
>>>> +++ b/src/intel_device.c
>>>> @@ -650,7 +650,10 @@ int __intel_peek_fd(ScrnInfoPtr scrn)
>>>>       dev = intel_device(scrn);
>>>>       assert(dev && dev->fd != -1);
>>>
>>> Doesn't Klocwork recognise the assert() above?
>>> I thought that would tell it that dev can't be NULL.
>>
>> It does not, I had to close many false positives related to this...
>
> Hmmm .. elsewhere (e.g. [4/7]) you have /added/ an assert, which I
> thought must be so that Klocwork stops complaining that something might
> be NULL ... maybe it can't handle the composite assertion? Does it
> silence the complaint if you change:
>      assert(dev && dev->fd != -1);
> into:
>      assert(dev);
>      assert(dev->fd != -1);
> ?

Sure, I added an assert, but not to silence patchwork, just to make sure 
we have no problem. I cannot run klokwork myself and my goal was not to 
silence but instead to check the reported issues.

David is right, I think Klokwork only cares about runtime checks and 
wants to make sure that we never de-reference a NULL pointer.

Martin


More information about the Intel-gfx mailing list