OSDN Git Service

Make drv_mapping_destroy() be called in release builds
authorJason Macnak <natsu@google.com>
Tue, 12 Nov 2019 18:53:05 +0000 (10:53 -0800)
committerCommit Bot <commit-bot@chromium.org>
Sat, 16 Nov 2019 19:34:52 +0000 (19:34 +0000)
The entire assert statement is currently being dropped when NDEBUG is defined
which causes mappings to never be cleaned up on bo destruction. When mappings
are not cleaned up, a new buffer that gets a recycled handle may find an old
mapping in drv_bo_map() which is not valid for the new buffer.

BUG=b:123764798
TEST=built and ran with cuttlefish locally

Change-Id: Ib7147c3f5ed3a2b84793dfc2b17236ee0d92ac13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1912760
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>

drv.c

diff --git a/drv.c b/drv.c
index ef5cbc5..872b5d4 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -320,6 +320,7 @@ struct bo *drv_bo_create_with_modifiers(struct driver *drv, uint32_t width, uint
 
 void drv_bo_destroy(struct bo *bo)
 {
+       int ret;
        size_t plane;
        uintptr_t total = 0;
        struct driver *drv = bo->drv;
@@ -335,7 +336,8 @@ void drv_bo_destroy(struct bo *bo)
        pthread_mutex_unlock(&drv->driver_lock);
 
        if (total == 0) {
-               assert(drv_mapping_destroy(bo) == 0);
+               ret = drv_mapping_destroy(bo);
+               assert(ret == 0);
                bo->drv->backend->bo_destroy(bo);
        }