tools: release context when card connection fails
This commit is contained in:
parent
bc4eeda573
commit
6472027848
|
@ -1127,7 +1127,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
action_count--;
|
action_count--;
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
if (card) {
|
if (card) {
|
||||||
sc_unlock(card);
|
sc_unlock(card);
|
||||||
sc_disconnect_card(card);
|
sc_disconnect_card(card);
|
||||||
|
|
|
@ -1076,6 +1076,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
err = util_connect_card(ctx, &card, opt_reader, opt_wait, verbose);
|
err = util_connect_card(ctx, &card, opt_reader, opt_wait, verbose);
|
||||||
|
if (err)
|
||||||
|
goto end;
|
||||||
printf("Using card driver: %s\n", card->driver->name);
|
printf("Using card driver: %s\n", card->driver->name);
|
||||||
|
|
||||||
if (do_create_pin_file) {
|
if (do_create_pin_file) {
|
||||||
|
|
|
@ -251,7 +251,7 @@ int main(int argc, char *argv[])
|
||||||
if (err)
|
if (err)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (opt_bind_to_aid) {
|
if (opt_bind_to_aid) {
|
||||||
struct sc_aid aid;
|
struct sc_aid aid;
|
||||||
|
|
||||||
aid.len = sizeof(aid.value);
|
aid.len = sizeof(aid.value);
|
||||||
|
|
|
@ -876,6 +876,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
r = util_connect_card(ctx, &card, opt_reader, opt_wait, verbose);
|
r = util_connect_card(ctx, &card, opt_reader, opt_wait, verbose);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
sc_release_context(ctx);
|
||||||
util_fatal("failed to connect to card: %s", sc_strerror(r));
|
util_fatal("failed to connect to card: %s", sc_strerror(r));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue