From 790d4422b2b4ec5f5e8025e4cf06ccfca3c767de Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Oct 2023 18:25:37 +0200 Subject: [PATCH] pan/bo: Make sure we catch refcnt underflows Recently had to debug an unbalanced ref/unref situation in some code I added, and having an assert(refcnt > 0) in panfrost_bo_unreference() would have made this simpler, so let's add one. Signed-off-by: Boris Brezillon Reviewed-by: Erik Faye-Lund Part-of: --- src/panfrost/lib/pan_bo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panfrost/lib/pan_bo.c b/src/panfrost/lib/pan_bo.c index b884cff4488..b84eeeef1b5 100644 --- a/src/panfrost/lib/pan_bo.c +++ b/src/panfrost/lib/pan_bo.c @@ -431,6 +431,7 @@ panfrost_bo_unreference(struct panfrost_bo *bo) return; /* Don't return to cache if there are still references */ + assert(p_atomic_read(&bo->refcnt) > 0); if (p_atomic_dec_return(&bo->refcnt)) return;