[PATCH 27/27] hw/usb/ccid-card-emulated: free libcacard context

Marc-AndrĂ© Lureau <[email protected]> Wed, 05 Aug 2026 15:51:17 +0400
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
libcacard uses a global context, but we can call finalize since
vcard_emul_init() would have failed earlier if a second card context was
used.

This fixes libtss2-fapi leaks spotted by ASAN.

Signed-off-by: Marc-AndrĂ© Lureau <[email protected]>
---
 hw/usb/ccid-card-emulated.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 985f21997aa8..6c8eec39faa9 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -580,6 +580,8 @@ static void emulated_unrealize(CCIDCardState *base)
     qemu_mutex_destroy(&card->handle_apdu_mutex);
     qemu_mutex_destroy(&card->vreader_mutex);
     qemu_mutex_destroy(&card->event_list_mutex);
+
+    vcard_emul_finalize();
 }
 
 static const Property emulated_card_properties[] = {

-- 
2.55.0