panfrost: Handle the bo == NULL case in panfrost_bo_[un]reference()
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 2 Aug 2019 17:18:47 +0000 (19:18 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Fri, 2 Aug 2019 19:54:58 +0000 (21:54 +0200)
Allows us to pass BOs without checking if they're NULL or not.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_resource.c

index 71da383d4c7ad21f89e8e95eb25038d2f2f13aa2..f74a39555b45fa114a78346cef7f4e82df3d66d5 100644 (file)
@@ -443,12 +443,16 @@ panfrost_resource_create(struct pipe_screen *screen,
 void
 panfrost_bo_reference(struct panfrost_bo *bo)
 {
-        pipe_reference(NULL, &bo->reference);
+        if (bo)
+                pipe_reference(NULL, &bo->reference);
 }
 
 void
 panfrost_bo_unreference(struct pipe_screen *screen, struct panfrost_bo *bo)
 {
+        if (!bo)
+                return;
+
         /* When the reference count goes to zero, we need to cleanup */
 
         if (pipe_reference(&bo->reference, NULL))