[Linaro-mm-sig] [PATCH 2/9] dma-buf: warn about dma_fence_array container rules

Christian König ckoenig.leichtzumerken at gmail.com
Fri Jan 21 11:00:59 UTC 2022



Am 21.01.22 um 08:31 schrieb Thomas Hellström:
>
> On 1/20/22 14:27, Christian König wrote:
>> It's not allowed to nest another dma_fence container into a 
>> dma_fence_array
>> or otherwise we can run into recursion.
>>
>> Warn about that when we create a dma_fence_array.
>>
>> Signed-off-by: Christian König <christian.koenig at amd.com>
>> Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
>> ---
>>   drivers/dma-buf/dma-fence-array.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/dma-buf/dma-fence-array.c 
>> b/drivers/dma-buf/dma-fence-array.c
>> index 3e07f961e2f3..4bfbcb885bbc 100644
>> --- a/drivers/dma-buf/dma-fence-array.c
>> +++ b/drivers/dma-buf/dma-fence-array.c
>> @@ -176,6 +176,19 @@ struct dma_fence_array 
>> *dma_fence_array_create(int num_fences,
>>         array->base.error = PENDING_ERROR;
>>   +    /* dma_fence_array objects should never contain any other fence
> Nit: First comment line of multi-line comments shouldn't contain text.
>> +     * containers or otherwise we run into recursion and potential 
>> kernel
>> +     * stack overflow on operations on the dma_fence_array.
>> +     *
>> +     * The correct way of handling this is to flatten out the array 
>> by the
>> +     * caller instead.
>> +     *
>> +     * Enforce this here by checking that we don't create a 
>> dma_fence_array
>> +     * with any container inside.
>> +     */
>> +    while (seqno--)
>> +        WARN_ON(dma_fence_is_container(fences[seqno]));
>> +
>
> s/seqno/num_fences/g ?

Ah, of course! Typing to fast.

Thanks,
Christian.

>
> Thanks,
>
> Thomas
>
>
>
>>       return array;
>>   }
>>   EXPORT_SYMBOL(dma_fence_array_create);
>



More information about the dri-devel mailing list