From patchwork Fri Oct 19 10:50:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10648975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CED23B73 for ; Fri, 19 Oct 2018 10:52:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C0B28A44 for ; Fri, 19 Oct 2018 10:52:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4A0828A3F; Fri, 19 Oct 2018 10:52:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C04028A44 for ; Fri, 19 Oct 2018 10:52:05 +0000 (UTC) Received: from localhost ([::1]:48529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDSNw-0006tC-Sj for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Oct 2018 06:52:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDSMq-0006GD-JY for qemu-devel@nongnu.org; Fri, 19 Oct 2018 06:50:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDSMn-0001Vl-Mi for qemu-devel@nongnu.org; Fri, 19 Oct 2018 06:50:56 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:42402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDSMn-0001MI-B1 for qemu-devel@nongnu.org; Fri, 19 Oct 2018 06:50:53 -0400 Received: by mail-pl1-x643.google.com with SMTP id c8-v6so15693100plo.9 for ; Fri, 19 Oct 2018 03:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3MiAi9NwHwQRV07isDLymR24Mzr2UtsMm0zxuBsFGyQ=; b=WA9q4brKcAJVqqtyZhaPsLv+Sfse/e418G/ujLI+JlxQKlyfD2yWcsg0fLIYntLB2i KMPynmsqfSPgS2298IFxgO4F+zv885Lm8Y542OXOWx+Cb5Q5sJYY8kBCVE0KFIMHEG4K 7t0Mnh8W4oPmYgLm//2tgnmPW/8u4xE49YtS6d37AGfAN9iaK0A+P5UtDhT0jwL0uWjR GXazgQDDQrKIanBaFaau+k5JyadTXhrm1XOJzBfwb+3DI481fUMltC+TUBz+dLASrKcR 77yW0nZOs/YrlRe3unC6h4DdMEVM6MgYjXfwJ1KU0ARpIzaP2XGNIm0f9RpLCMPILm9W kOMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3MiAi9NwHwQRV07isDLymR24Mzr2UtsMm0zxuBsFGyQ=; b=aeswENfy8JbpzPOfsei6JSiL7sBO5uE34sVNSrBhHM0i2Y5HjiMVs7FV/qxNjmRo8O sS78Et1XE9xp97fgexb4sh5K92Ysa515CM8Dbn7VaqkRFGNVkLdx6x5Utjo+yDLFP3De mrIJoicoYuMIq82R/Rlk6g2ezMhkIdbPlX37uWzIUnqN9LsC51+c/FycjuCtiDsb3mAq Aq0YG6Rkrbu9RXIxF35V7EEktaZ58PSRC8W8uI8oSx2TCItFeQYNlHUar2PCGPNlHCWV 4sL1f/yOv5b/QojEPZOFPhXLEcehOh4E7biJECc/rCfR3RBHvw8J1FE5+HAnmnv4Rksv k5+A== X-Gm-Message-State: ABuFfohOyn4/qv1YiQlU5MfARiGszolP1jAwiLxTArmls9IpG48bTbGs b0+pFtdK9qp+adGHO/Morio= X-Google-Smtp-Source: ACcGV62ERnXssowFGmP/WHEA2KbZ6N2m+M5RLVD66kUXJEJ21XoN8xgHiW3XkbSvnxDwRl9BfcLc8w== X-Received: by 2002:a17:902:4383:: with SMTP id j3-v6mr30098556pld.265.1539946243744; Fri, 19 Oct 2018 03:50:43 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id t64-v6sm42884856pfb.44.2018.10.19.03.50.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 03:50:43 -0700 (PDT) From: Li Qiang To: kraxel@redhat.com Date: Fri, 19 Oct 2018 03:50:35 -0700 Message-Id: <1539946236-18028-2-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539946236-18028-1-git-send-email-liq3ea@gmail.com> References: <1539946236-18028-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH 1/2] hw: ccid-card-emulated: introduce clean_event_notifier 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: Li Qiang , liq3ea@163.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Call it in device unrealize function. Signed-off-by: Li Qiang --- hw/usb/ccid-card-emulated.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 5c8b3c9..b356edb 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -409,6 +409,12 @@ static int init_event_notifier(EmulatedState *card, Error **errp) return 0; } +static void clean_event_notifier(EmulatedState *card) +{ + event_notifier_set_handler(&card->notifier, NULL); + event_notifier_cleanup(&card->notifier); +} + #define CERTIFICATES_DEFAULT_DB "/etc/pki/nssdb" #define CERTIFICATES_ARGS_TEMPLATE\ "db=\"%s\" use_hw=no soft=(,Virtual Reader,CAC,,%s,%s,%s)" @@ -556,6 +562,7 @@ static void emulated_unrealize(CCIDCardState *base, Error **errp) qemu_cond_signal(&card->handle_apdu_cond); qemu_thread_join(&card->apdu_thread_id); + clean_event_notifier(card); /* threads exited, can destroy all condvars/mutexes */ qemu_cond_destroy(&card->handle_apdu_cond); qemu_mutex_destroy(&card->handle_apdu_mutex);