While trying to replicate a weird drm_exec lock alloc tracking warning using the drm_exec kunit test, the warning was shadowed by a UAF warning due to a bug in the drm kunit helpers. Patch 1 fixes that drm kunit UAF. Patch 2 introduces a drm_exec kunit subtest that shows the weird lock alloc tracking warning if CONFIG_DEBUG_LOCK_ALLOC is set. Patch 3 modifies drm_exec to avoid that lock alloc tracking warning. Although the proper fix would probably be to modify lockdep to track the lock held status differently, this workaround at pushes the problem out of drm_exec, so that any drm_exec users relying on its refcounting don't run into this. Cc: Christian König <christian.koenig@xxxxxxx> Cc: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> Cc: Danilo Krummrich <dakr@xxxxxxxxxx> Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx Thomas Hellström (3): drm/kunit: Avoid a driver uaf drm/tests/drm_exec: Add a test for object freeing within drm_exec_fini() drm/drm_exec: Work around a WW mutex lockdep oddity drivers/gpu/drm/drm_exec.c | 2 +- drivers/gpu/drm/tests/drm_exec_test.c | 47 +++++++++++++++++++++++++++ include/drm/drm_exec.h | 35 +++++++++++++++++--- include/drm/drm_kunit_helpers.h | 4 ++- 4 files changed, 82 insertions(+), 6 deletions(-) -- 2.41.0