libdrm/intel: assert that clients are using bo refcounting correctly
Add assertions to drm_intel_gem_bo_reference, drm_intel_gem_bo_reference_locked and drm_intel_gem_bo_unreference_locked that the object has not been freed (refcount > 0). Mistakes in refcounting lead to attempts to insert a bo into a free list more than once which causes application failure as empty free lists are dereferenced as buffer objects. Signed-off-by: Keith Packard <keithp@keithp.com>main
parent
11b60973bc
commit
68103b2758
|
@ -505,6 +505,7 @@ drm_intel_gem_bo_reference(drm_intel_bo *bo)
|
||||||
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
|
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
|
||||||
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
||||||
|
|
||||||
|
assert(bo_gem->refcount > 0);
|
||||||
pthread_mutex_lock(&bufmgr_gem->lock);
|
pthread_mutex_lock(&bufmgr_gem->lock);
|
||||||
bo_gem->refcount++;
|
bo_gem->refcount++;
|
||||||
pthread_mutex_unlock(&bufmgr_gem->lock);
|
pthread_mutex_unlock(&bufmgr_gem->lock);
|
||||||
|
@ -515,6 +516,7 @@ drm_intel_gem_bo_reference_locked(drm_intel_bo *bo)
|
||||||
{
|
{
|
||||||
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
||||||
|
|
||||||
|
assert(bo_gem->refcount > 0);
|
||||||
bo_gem->refcount++;
|
bo_gem->refcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,6 +551,7 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo)
|
||||||
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
|
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
|
||||||
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
|
||||||
|
|
||||||
|
assert(bo_gem->refcount > 0);
|
||||||
if (--bo_gem->refcount == 0) {
|
if (--bo_gem->refcount == 0) {
|
||||||
struct drm_intel_gem_bo_bucket *bucket;
|
struct drm_intel_gem_bo_bucket *bucket;
|
||||||
uint32_t tiling_mode;
|
uint32_t tiling_mode;
|
||||||
|
|
Loading…
Reference in New Issue