From 5c8124b8b9554c7843feccf408648c9689bce243 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 22 Jul 2021 11:22:47 +0900 Subject: scd: Small clean up for card access. * scd/app.c (app_get_challenge): Remove the check to ref_count. * scd/command.c (send_client_notifications): Update comments. Signed-off-by: NIIBE Yutaka --- scd/app.c | 9 +-------- scd/command.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scd/app.c b/scd/app.c index fafd28cee..678d058f0 100644 --- a/scd/app.c +++ b/scd/app.c @@ -2204,18 +2204,11 @@ gpg_error_t app_get_challenge (card_t card, ctrl_t ctrl, size_t nbytes, unsigned char *buffer) { - gpg_error_t err; - (void)ctrl; if (!nbytes || !buffer) return gpg_error (GPG_ERR_INV_VALUE); - if (!card->ref_count) - err = gpg_error (GPG_ERR_CARD_NOT_INITIALIZED); - else - err = iso7816_get_challenge (card->slot, nbytes, buffer); - - return err; + return iso7816_get_challenge (card->slot, nbytes, buffer); } diff --git a/scd/command.c b/scd/command.c index 5ba71a4aa..0819318e7 100644 --- a/scd/command.c +++ b/scd/command.c @@ -2851,8 +2851,16 @@ popup_prompt (void *opaque, int on) } -/* Helper to send the clients a status change notification. Note that - * this function assumes that APP is already locked. */ +/* + * Helper to send the clients a status change notification. + * + * When it's removal of card, this function also clean up all + * references by ctrl->card_ctx of all sessions. + * + * Note that this function assumes that all accesses to cards and + * applications are locked. By the mrsw-lock, it is guaranteed that + * no card/app is accessed, when this function is called.. + */ void send_client_notifications (card_t card, int removal) { -- cgit v1.2.3