* [Qemu-devel] [PATCH] hw/usb: fix mistaken de-initialization of CCID state
@ 2018-12-21 13:41 Daniel P. Berrangé
2018-12-21 14:46 ` Michael Tokarev
2018-12-21 15:19 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2018-12-21 13:41 UTC (permalink / raw)
To: qemu-devel
Cc: Michael Tokarev, qemu-stable, qemu-trivial, Daniel P. Berrangé
In previous commit:
commit 7dea29e4af17fc1d27478de9f8ea38144deac54a
Author: Li Qiang <liq3ea@gmail.com>
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=ccid0 -device ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ccid0.0
qemu-system-x86_64: util/qemu-thread-posix.c:64: qemu_mutex_lock_impl: Assertion `mutex->initialized' failed.
Aborted (core dumped)
Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
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_thread,
card, QEMU_THREAD_JOINABLE);
+ return;
+
out2:
clean_event_notifier(card);
out1:
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb: fix mistaken de-initialization of CCID state
2018-12-21 13:41 [Qemu-devel] [PATCH] hw/usb: fix mistaken de-initialization of CCID state Daniel P. Berrangé
@ 2018-12-21 14:46 ` Michael Tokarev
2018-12-21 15:19 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2018-12-21 14:46 UTC (permalink / raw)
To: Daniel P. Berrangé, qemu-devel; +Cc: qemu-stable, qemu-trivial
21.12.2018 16:41, Daniel P. Berrangé wrote:
> In previous commit:
>
> commit 7dea29e4af17fc1d27478de9f8ea38144deac54a
> Author: Li Qiang <liq3ea@gmail.com>
> Date: Fri Oct 19 03:50:36 2018 -0700
[]
> --- 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_thread,
> card, QEMU_THREAD_JOINABLE);
>
> + return;
> +
> out2:
> clean_event_notifier(card);
> out1:
Lovely :)
Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>
/mjt
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/usb: fix mistaken de-initialization of CCID state
2018-12-21 13:41 [Qemu-devel] [PATCH] hw/usb: fix mistaken de-initialization of CCID state Daniel P. Berrangé
2018-12-21 14:46 ` Michael Tokarev
@ 2018-12-21 15:19 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-12-21 15:19 UTC (permalink / raw)
To: Daniel P. Berrangé, qemu-devel
Cc: qemu-trivial, Michael Tokarev, qemu-stable
On 12/21/18 2:41 PM, Daniel P. Berrangé wrote:
> In previous commit:
>
> commit 7dea29e4af17fc1d27478de9f8ea38144deac54a
> Author: Li Qiang <liq3ea@gmail.com>
> 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=ccid0 -device ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ccid0.0
> qemu-system-x86_64: util/qemu-thread-posix.c:64: qemu_mutex_lock_impl: Assertion `mutex->initialized' failed.
> Aborted (core dumped)
>
> Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Fixes: 7dea29e4af1
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> 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_thread,
> card, QEMU_THREAD_JOINABLE);
>
> + return;
> +
> out2:
> clean_event_notifier(card);
> out1:
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-21 15:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-21 13:41 [Qemu-devel] [PATCH] hw/usb: fix mistaken de-initialization of CCID state Daniel P. Berrangé
2018-12-21 14:46 ` Michael Tokarev
2018-12-21 15:19 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.