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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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@xxxxxxx>
Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
  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);





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux