aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-08 17:34:20 +0200
committerKévin Redon <kredon@sysmocom.de>2018-07-11 22:01:58 +0200
commitb37bda0b55fbd474a45235c96d6283745b74bd8b (patch)
treecd618ac58306c7a34fdda752cfcba3653e653d9c
parentc6b968067d4a2bc7a825f95e1976051d2a67ec87 (diff)
sniffer: only allocate USB message if queue is not too long
When the host does not retrieved the USB messages, they keep getting queue in the firmware, filling the RAM, and preventing further memory to be allocated. Change-Id: I0e447acdf757dcb5dc5c4d8b84a4235866914cad
-rw-r--r--firmware/libcommon/source/sniffer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index 1c691af..0ca71a5 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -226,6 +226,14 @@ static void update_wt(uint8_t wi, uint8_t d)
*/
static struct msgb *usb_msg_alloc_hdr(uint8_t ep, uint8_t msg_class, uint8_t msg_type)
{
+ /* Only allocate message if not too many are already in the queue */
+ struct llist_head *head = usb_get_queue(SIMTRACE_USB_EP_CARD_DATAIN);
+ if (!head) {
+ return NULL;
+ }
+ if (llist_count(head) > 5) {
+ return NULL;
+ }
struct msgb *usb_msg = usb_buf_alloc(SIMTRACE_USB_EP_CARD_DATAIN);
if (!usb_msg) {
return NULL;