iris: Do not dereference nullptr with pipe_reference
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Fri, 14 Feb 2020 13:37:23 +0000 (15:37 +0200)
committerDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Wed, 19 Feb 2020 10:07:24 +0000 (12:07 +0200)
../src/gallium/drivers/iris/iris_fence.h:54:8: runtime error: member access within null pointer of type 'struct iris_syncpt'

../src/gallium/drivers/iris/iris_fence.c:136:8: runtime error: member access within null pointer of type 'struct pipe_fence_handle'

Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3825>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3825>

src/gallium/drivers/iris/iris_fence.c
src/gallium/drivers/iris/iris_fence.h

index b163ef5a23b09fcf1c31b78f78705cb2b9565162..d8c3bd932ce7a9f798409b5720dd9b8dc265563f 100644 (file)
@@ -133,7 +133,8 @@ iris_fence_reference(struct pipe_screen *p_screen,
                      struct pipe_fence_handle **dst,
                      struct pipe_fence_handle *src)
 {
-   if (pipe_reference(&(*dst)->ref, &src->ref))
+   if (pipe_reference(*dst ? &(*dst)->ref : NULL,
+                      src ? &src->ref : NULL))
       iris_fence_destroy(p_screen, *dst);
 
    *dst = src;
index caf2ceeb3151442ffcededf82e0f828977c0e5b4..0ce5fa8ebfb7a0d45b35dd149d3b6afaf821d218 100644 (file)
@@ -51,7 +51,8 @@ iris_syncpt_reference(struct iris_screen *screen,
                       struct iris_syncpt **dst,
                       struct iris_syncpt *src)
 {
-   if (pipe_reference(&(*dst)->ref, &src->ref))
+   if (pipe_reference(*dst ? &(*dst)->ref : NULL,
+                      src ? &src->ref: NULL))
       iris_syncpt_destroy(screen, *dst);
 
    *dst = src;