tools: release context when card connection fails

This commit is contained in:
Frank Morgner 2019-03-06 19:54:35 +01:00 committed by Martin Paljak
parent bc4eeda573
commit 6472027848
4 changed files with 5 additions and 2 deletions

View File

@ -1127,7 +1127,7 @@ int main(int argc, char *argv[])
}
action_count--;
}
end:
end:
if (card) {
sc_unlock(card);
sc_disconnect_card(card);

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}