[2/9] dma-buf: make to_dma_fence_array NULL safe
diff mbox series

Message ID 20190826145731.1725-3-christian.koenig@amd.com
State New
Headers show
Series
  • [1/9] dma-buf: fix dma_fence_array_signaled
Related show

Commit Message

Christian König Aug. 26, 2019, 2:57 p.m. UTC
A bit surprising that this wasn't already the case.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 include/linux/dma-fence-array.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ruhl, Michael J Aug. 30, 2019, 4:07 p.m. UTC | #1
>-----Original Message-----
>From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf
>Of Christian König
>Sent: Monday, August 26, 2019 10:57 AM
>To: dri-devel@lists.freedesktop.org; chris@chris-wilson.co.uk;
>daniel.vetter@ffwll.ch; sumit.semwal@linaro.org; linux-
>media@vger.kernel.org; linaro-mm-sig@lists.linaro.org
>Subject: [PATCH 2/9] dma-buf: make to_dma_fence_array NULL safe
>
>A bit surprising that this wasn't already the case.
>
>Signed-off-by: Christian König <christian.koenig@amd.com>
>---
> include/linux/dma-fence-array.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-
>array.h
>index 303dd712220f..f99cd7eb24e0 100644
>--- a/include/linux/dma-fence-array.h
>+++ b/include/linux/dma-fence-array.h
>@@ -68,7 +68,7 @@ static inline bool dma_fence_is_array(struct dma_fence
>*fence)
> static inline struct dma_fence_array *
> to_dma_fence_array(struct dma_fence *fence)
> {
>-	if (fence->ops != &dma_fence_array_ops)
>+	if (!fence || fence->ops != &dma_fence_array_ops)
> 		return NULL;
>
> 	return container_of(fence, struct dma_fence_array, base);

It looks like dma_fence_is_array() has the same issue.

Is it worth fixing?

Mike


>--
>2.17.1
>
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox series

diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
index 303dd712220f..f99cd7eb24e0 100644
--- a/include/linux/dma-fence-array.h
+++ b/include/linux/dma-fence-array.h
@@ -68,7 +68,7 @@  static inline bool dma_fence_is_array(struct dma_fence *fence)
 static inline struct dma_fence_array *
 to_dma_fence_array(struct dma_fence *fence)
 {
-	if (fence->ops != &dma_fence_array_ops)
+	if (!fence || fence->ops != &dma_fence_array_ops)
 		return NULL;
 
 	return container_of(fence, struct dma_fence_array, base);