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 <m.tretter@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23743>
This commit is contained in:
Michael Tretter 2023-06-20 15:14:52 +02:00 committed by Marge Bot
parent 279d08a18a
commit ee62f4629a

View file

@ -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;