Module: Mesa
Branch: main
Commit: ee62f4629a4da6a4e0e1ea011941d7cccb7b41a9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee62f4629a4da6a4e0e1ea011941d7cccb7b41a9

Author: Michael Tretter <[email protected]>
Date:   Tue Jun 20 15:14:52 2023 +0200

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23743>

---

 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;
 

Reply via email to