From 1f9838513258526b52b8063efa1126c1af7f92db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sat, 25 Apr 2026 01:00:35 +0400 Subject: [PATCH] backends/cryptodev-lkcf: skip cleanup when not initialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cryptodev_lkcf_cleanup() locks a mutex that is only initialized during the init vfunc (called at realize time). When the backend is destroyed without ever being realized, the mutex is uninitialized and the lock aborts. Return early from cleanup when the backend was never started. Note: it looks like cryptodev init/cleanup callbacks should rather be regular complete/finalize overrides (calling the parent method). Fixes: 39fff6f3e8b3 ("cryptodev: Add a lkcf-backend for cryptodev") Reviewed-by: Daniel P. Berrangé Signed-off-by: Marc-André Lureau --- backends/cryptodev-lkcf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 40c7bd3c5a..3fe29d3104 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -255,6 +255,10 @@ static void cryptodev_lkcf_cleanup(CryptoDevBackend *backend, Error **errp) CryptoDevBackendClient *cc; CryptoDevLKCFTask *task, *next; + if (!cryptodev_backend_is_ready(backend)) { + return; + } + qemu_mutex_lock(&lkcf->mutex); lkcf->running = false; qemu_mutex_unlock(&lkcf->mutex);