This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
tsaitgaist gerrit-no-reply at lists.osmocom.orgtsaitgaist has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/16097 ) Change subject: free USB buffer when allocation failed ...................................................................... free USB buffer when allocation failed when the reader sends APDU headers (e.g. after multiple reset), messages are queued for USB transmission. but if no host software is connected to SIMtrace in card emulation mode, the USB message queue is not emptied, leading to the memory getting full and preventing allocation for newer messages (e.g. more recent APDU). in this case the oldest queued message is now dropped to free some memory. Change-Id: Ie9ebdd2ff966f67c9afd1ed760f106558f0091ad --- M firmware/libcommon/source/card_emu.c 1 file changed, 27 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/97/16097/1 diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index 5298ffc..497b963 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -254,12 +254,35 @@ /* Allocate USB buffer and push + initialize simtrace_msg_hdr */ struct msgb *usb_buf_alloc_st(uint8_t ep, uint8_t msg_class, uint8_t msg_type) { - struct msgb *msg; + struct msgb *msg = NULL; struct simtrace_msg_hdr *sh; - msg = usb_buf_alloc(ep); - if (!msg) - return NULL; + while (!msg) { + msg = usb_buf_alloc(ep); // try to allocate some memory + if (!msg) { // allocation failed, we might be out of memory + struct llist_head *queue = usb_get_queue(ep); + if (!queue) { + TRACE_ERROR("ep %u: %s queue does not exist\n\r", + ep, __func__); + return NULL; + } + if (llist_empty(queue)) { + TRACE_ERROR("ep %u: %s EOMEM (queue already empty)\n\r", + ep, __func__); + return NULL; + } + msg = msgb_dequeue(queue); + if (!msg) { + TRACE_ERROR("ep %u: %s no msg in non-empty queue\n\r", + ep, __func__); + return NULL; + } + usb_buf_free(msg); + msg = NULL; + TRACE_DEBUG("ep %u: %s queue msg dropped\n\r", + ep, __func__); + } + } msg->l1h = msgb_put(msg, sizeof(*sh)); sh = (struct simtrace_msg_hdr *) msg->l1h; -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/16097 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: Ie9ebdd2ff966f67c9afd1ed760f106558f0091ad Gerrit-Change-Number: 16097 Gerrit-PatchSet: 1 Gerrit-Owner: tsaitgaist <kredon at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191118/41cba7db/attachment.htm>