lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9122ec2e-8729-0542-22e1-98a81fe3f3f2@amd.com>
Date:   Fri, 10 Jun 2022 10:00:00 +0200
From:   Christian König <christian.koenig@....com>
To:     Jiabing Wan <wanjiabing@...o.com>,
        Sumit Semwal <sumit.semwal@...aro.org>,
        Daniel Vetter <daniel.vetter@...ll.ch>,
        linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
        linaro-mm-sig@...ts.linaro.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] dma-buf: Don't use typeof in va_arg

Am 10.06.22 um 09:52 schrieb Jiabing Wan:
>
>
> On 2022/6/10 15:24, Christian König wrote:
>> Am 10.06.22 um 09:20 schrieb Wan Jiabing:
>>> Fix following coccicheck warning:
>>> ./drivers/dma-buf/st-dma-fence-unwrap.c:75:39-45: ERROR: reference 
>>> preceded by free on line 70
>>>
>>> Use 'struct dma_fence *' instead of 'typeof(*fences)' to avoid this
>>> warning and also fix other 'typeof(*fences)' to make them consistent.
>>
>> Well that doesn't looks correct to me.
>>
>> *fence should be valid at this point, why does coccicheck things it 
>> is freed?
>
> *fence is valid. Coccicheck reports this because fence is freed.
> But use 'struct dma_fence *' can avoid this wrong report.

Well in this case that's just a clear NAK.

Using typeof(*var) is perfectly valid and preferred should the type 
change at some point.

As far as I can see your cocci script is somehow reporting a false warning.

Regards,
Christian.

>
> I also grep all code and find it's unusual to use 'typeof' in va_arg, 
> only two files.
>
> grep -R "va_arg("  . | grep 'typeof'
> ./drivers/dma-buf/st-dma-fence-unwrap.c:                fences[i] = 
> va_arg(valist, typeof(*fences));
> ./drivers/dma-buf/st-dma-fence-unwrap.c: dma_fence_put(va_arg(valist, 
> typeof(*fences)));
> ./lib/test_scanf.c:             typeof(*expect) got = *va_arg(ap, 
> typeof(expect));              \
>
> And other files all use declaration name directly.
> So I send this patch makes code clearer and fix the wrong warning by 
> the way.
>
> Thanks,
> Wan Jiabing
>
>>
>> Regards,
>> Christian.
>>
>>>
>>> Fixes: 0c5064fa8d5a ("dma-buf: cleanup dma_fence_unwrap selftest v2")
>>> Signed-off-by: Wan Jiabing <wanjiabing@...o.com>
>>> ---
>>>   drivers/dma-buf/st-dma-fence-unwrap.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c 
>>> b/drivers/dma-buf/st-dma-fence-unwrap.c
>>> index 4105d5ea8dde..1137a6d90b32 100644
>>> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
>>> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
>>> @@ -56,7 +56,7 @@ static struct dma_fence *mock_array(unsigned int 
>>> num_fences, ...)
>>>         va_start(valist, num_fences);
>>>       for (i = 0; i < num_fences; ++i)
>>> -        fences[i] = va_arg(valist, typeof(*fences));
>>> +        fences[i] = va_arg(valist, struct dma_fence *);
>>>       va_end(valist);
>>>         array = dma_fence_array_create(num_fences, fences,
>>> @@ -72,7 +72,7 @@ static struct dma_fence *mock_array(unsigned int 
>>> num_fences, ...)
>>>   error_put:
>>>       va_start(valist, num_fences);
>>>       for (i = 0; i < num_fences; ++i)
>>> -        dma_fence_put(va_arg(valist, typeof(*fences)));
>>> +        dma_fence_put(va_arg(valist, struct dma_fence *));
>>>       va_end(valist);
>>>       return NULL;
>>>   }
>>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ