From nobody Fri Nov 7 07:32:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546962975172705.3822124242251; Tue, 8 Jan 2019 07:56:15 -0800 (PST) Received: from localhost ([127.0.0.1]:51049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggtjc-0005II-6A for importer@patchew.org; Tue, 08 Jan 2019 10:56:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggthd-0003rr-Ih for qemu-devel@nongnu.org; Tue, 08 Jan 2019 10:54:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggthc-0006ae-Ev for qemu-devel@nongnu.org; Tue, 08 Jan 2019 10:54:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51974) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggthc-0006XM-88 for qemu-devel@nongnu.org; Tue, 08 Jan 2019 10:54:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A4ABC056797; Tue, 8 Jan 2019 15:54:02 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id B40735D9C9; Tue, 8 Jan 2019 15:53:55 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E80759819; Tue, 8 Jan 2019 16:53:54 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 8 Jan 2019 16:53:50 +0100 Message-Id: <20190108155354.8591-2-kraxel@redhat.com> In-Reply-To: <20190108155354.8591-1-kraxel@redhat.com> References: <20190108155354.8591-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 08 Jan 2019 15:54:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/5] hw/usb: fix mistaken de-initialization of CCID state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Daniel P. Berrang=C3=A9 In previous commit: commit 7dea29e4af17fc1d27478de9f8ea38144deac54a Author: Li Qiang Date: Fri Oct 19 03:50:36 2018 -0700 hw: ccid-card-emulated: cleanup resource when realize in error path The emulated_realize method was changed so that it jumps to a cleanup label to de-initialize state upon error. This change failed to ensure the success path exited the method before this point though. So the mutexes are always destroyed even in normal operation. The result is as crashtastic as expected: $ qemu-system-x86_64 -usb -device usb-ccid,id=3Dccid0 -device ccid-card-emu= lated,backend=3Dnss-emulated,id=3Dsmartcard0,bus=3Dccid0.0 qemu-system-x86_64: util/qemu-thread-posix.c:64: qemu_mutex_lock_impl: Asse= rtion `mutex->initialized' failed. Aborted (core dumped) Fixes: 7dea29e4af1 Reported-by: Michael Tokarev Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael Tokarev Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20181221134115.27973-1-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- 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 25976ed84f..e0457d305b 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -549,6 +549,8 @@ static void emulated_realize(CCIDCardState *base, Error= **errp) qemu_thread_create(&card->apdu_thread_id, "ccid/apdu", handle_apdu_thr= ead, card, QEMU_THREAD_JOINABLE); =20 + return; + out2: clean_event_notifier(card); out1: --=20 2.9.3