From 77c2c1230bbd38cb87448382462fffb3c37c698b Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Fri, 19 Feb 2021 00:15:43 +0100 Subject: [PATCH] drivers: usb_dc_native_posix: do not use IN callback without reason Call the IN callback only if data in usb_dc_ep_write() is actually written to the intermediate buffer and sent. Signed-off-by: Johann Fischer --- drivers/usb/device/usb_dc_native_posix.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/device/usb_dc_native_posix.c b/drivers/usb/device/usb_dc_native_posix.c index dc51bb81181..06a3f9f532a 100644 --- a/drivers/usb/device/usb_dc_native_posix.c +++ b/drivers/usb/device/usb_dc_native_posix.c @@ -577,8 +577,14 @@ int handle_usb_data(struct usbip_header *hdr) LOG_HEXDUMP_DBG(ep_ctrl->buf, ep_ctrl->buf_len, ">"); - /* Indicate data sent */ - ep_ctrl->cb(ep, USB_DC_EP_DATA_IN); + /* + * Call the callback only if data in usb_dc_ep_write() + * is actually written to the intermediate buffer and sent. + */ + if (ep_ctrl->buf_len != 0) { + ep_ctrl->cb(ep, USB_DC_EP_DATA_IN); + usbip_ctrl.in_ep_ctrl[ep_idx].buf_len = 0; + } } return 0;