Skip to content

Commit 6476ff1

Browse files
fix(ncm): Return invalid NTBs to free list
In case we received invalid datagram, we silently fail a the buffer was not returned to empty list -> it was lost. If this happened more than CFG_TUD_NCM_OUT_NTB_N times, we run out of NTBs and all OUT transfers are NACKed. Closes espressif/esp-usb#107
1 parent 880aae4 commit 6476ff1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/class/net/ncm_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
857857
// - if there is a free receive buffer, initiate reception
858858
if (!recv_validate_datagram(ncm_interface.recv_tinyusb_ntb, xferred_bytes)) {
859859
// verification failed: ignore NTB and return it to free
860-
TU_LOG_DRV("(EE) VALIDATION FAILED. WHAT CAN WE DO IN THIS CASE?\n");
860+
TU_LOG_DRV("Invalid datatagram. Ignoring NTB\n");
861+
recv_put_ntb_into_free_list(ncm_interface.recv_tinyusb_ntb);
861862
} else {
862863
// packet ok -> put it into ready list
863864
recv_put_ntb_into_ready_list(ncm_interface.recv_tinyusb_ntb);

0 commit comments

Comments
 (0)