Skip to content

Commit e4e49c8

Browse files
Correctly close the slots of a multi-slots reader (serial)
Same patch as a1ccc12 but for the serial driver.
1 parent 3a3373d commit e4e49c8

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/ccid_serial.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ static status_t set_ccid_descriptor(CcidDesc * ccid_reader,
512512
ccid_reader->device = previous_ccid_reader->device;
513513

514514
*ccid_reader->device.nb_opened_slots += 1;
515+
ccid_reader->device.previous_slot = previous_ccid_reader;
515516
ccid_reader->device.ccid.bCurrentSlotIndex++;
516517
ccid_reader->device.ccid.dwSlotStatus = IFD_ICC_PRESENT;
517518
DEBUG_INFO2("Opening slot: %d",
@@ -562,6 +563,7 @@ static status_t set_ccid_descriptor(CcidDesc * ccid_reader,
562563
ccid_reader->device.ccid.pbSeq = &ccid_reader->device.ccid.real_bSeq;
563564
ccid_reader->device.real_nb_opened_slots = 1;
564565
ccid_reader->device.nb_opened_slots = &ccid_reader->device.real_nb_opened_slots;
566+
ccid_reader->device.previous_slot = NULL;
565567
ccid_reader->device.ccid.bCurrentSlotIndex = 0;
566568

567569
ccid_reader->device.ccid.dwMaxCCIDMessageLength = 271;
@@ -895,6 +897,17 @@ status_t CloseSerial(CcidDesc * ccid_reader)
895897

896898
free(ccid_reader->device.device);
897899
ccid_reader->device.device = NULL;
900+
901+
CcidDesc *tmp_reader = ccid_reader;
902+
while (tmp_reader)
903+
{
904+
CcidDesc *previous_slot = tmp_reader->device.previous_slot;
905+
906+
Log2(PCSC_LOG_INFO, "Release lun: %X", tmp_reader->lun);
907+
ReleaseReaderIndex(tmp_reader->reader_index);
908+
909+
tmp_reader = previous_slot;
910+
}
898911
}
899912

900913
return STATUS_SUCCESS;

src/defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ typedef struct
215215
*/
216216
int real_nb_opened_slots;
217217
int *nb_opened_slots;
218+
struct CCID_DESC *previous_slot;
218219

219220
/*
220221
* does the reader echoes the serial communication bytes?

0 commit comments

Comments
 (0)