diff --git a/src/tools/cardos-tool.c b/src/tools/cardos-tool.c index f35c99e2..cb292c51 100644 --- a/src/tools/cardos-tool.c +++ b/src/tools/cardos-tool.c @@ -1127,7 +1127,7 @@ int main(int argc, char *argv[]) } action_count--; } - end: +end: if (card) { sc_unlock(card); sc_disconnect_card(card); diff --git a/src/tools/cryptoflex-tool.c b/src/tools/cryptoflex-tool.c index b0cd6ede..2048871f 100644 --- a/src/tools/cryptoflex-tool.c +++ b/src/tools/cryptoflex-tool.c @@ -1076,6 +1076,8 @@ int main(int argc, char *argv[]) } err = util_connect_card(ctx, &card, opt_reader, opt_wait, verbose); + if (err) + goto end; printf("Using card driver: %s\n", card->driver->name); if (do_create_pin_file) { diff --git a/src/tools/iasecc-tool.c b/src/tools/iasecc-tool.c index 11a68b84..645373e1 100644 --- a/src/tools/iasecc-tool.c +++ b/src/tools/iasecc-tool.c @@ -251,7 +251,7 @@ int main(int argc, char *argv[]) if (err) goto end; - if (opt_bind_to_aid) { + if (opt_bind_to_aid) { struct sc_aid aid; aid.len = sizeof(aid.value); diff --git a/src/tools/openpgp-tool.c b/src/tools/openpgp-tool.c index 13a1057d..3e4ce527 100644 --- a/src/tools/openpgp-tool.c +++ b/src/tools/openpgp-tool.c @@ -876,6 +876,7 @@ int main(int argc, char **argv) r = util_connect_card(ctx, &card, opt_reader, opt_wait, verbose); if (r) { + sc_release_context(ctx); util_fatal("failed to connect to card: %s", sc_strerror(r)); return EXIT_FAILURE; }