From daa2cec6a543f06a2e408d97a80a5041027f16a9 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 17 Jul 2020 20:42:38 +0900 Subject: [PATCH] scd: Fix closing reader and reeleasing context in PC/SC. * scd/apdu.c (close_pcsc_reader): Unlock the reader_table_lock. (apdu_dev_list_finish): Release the context when no readers. -- Fixes-commit: 46d185f60397f68830bfdfb99627b29aea5016f1 Signed-off-by: NIIBE Yutaka --- scd/apdu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scd/apdu.c b/scd/apdu.c index 33951a2da..8b3b5694c 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -821,6 +821,7 @@ close_pcsc_reader (int slot) pcsc.context = 0; for (i = 0; i < MAX_READER; i++) pcsc.rdrname[i] = NULL; + npth_mutex_unlock (&reader_table_lock); } return 0; } @@ -2061,6 +2062,12 @@ apdu_dev_list_finish (struct dev_list *dl) xfree (dl->table); for (i = 0; i < MAX_READER; i++) pcsc.rdrname[i] = NULL; + + if (pcsc.count == 0) + { + pcsc_release_context (pcsc.context); + pcsc.context = 0; + } } xfree (dl); npth_mutex_unlock (&reader_table_lock);