From ee62f4629a4da6a4e0e1ea011941d7cccb7b41a9 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Tue, 20 Jun 2023 15:14:52 +0200 Subject: [PATCH] kmsro: assert that scanout refcount is larger than 0 The dumb buffer backing the renderonly_scanout is only destroyed if the refcount reaches zero. If a driver does not correctly initialize the refcount, the refcount may be negative and the buffer will never be freed. Add an assert to ensure that drivers correctly initialize the refcount. Signed-off-by: Michael Tretter Part-of: --- src/gallium/auxiliary/renderonly/renderonly.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/renderonly/renderonly.c b/src/gallium/auxiliary/renderonly/renderonly.c index fc09f16a167..8ec58e638a6 100644 --- a/src/gallium/auxiliary/renderonly/renderonly.c +++ b/src/gallium/auxiliary/renderonly/renderonly.c @@ -43,6 +43,7 @@ renderonly_scanout_destroy(struct renderonly_scanout *scanout, { struct drm_mode_destroy_dumb destroy_dumb = {0}; + assert(p_atomic_read(&scanout->refcnt) > 0); if (p_atomic_dec_return(&scanout->refcnt)) return;