mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user