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
This commit is contained in:
Kévin Redon
2018-07-08 17:34:20 +02:00
parent c6b968067d
commit b37bda0b55

View File

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