From 9f3c0b1e385abc8c9187672442c242a22438bb41 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 2 Sep 2022 18:38:54 +0800 Subject: [PATCH] usb_host: Fix incorrect memset() usage in HCD This commit fixes incorrect usage of memset() in the HCD's various _buffer_parse_...() functions. The memset was not clearing the qtd lists, and were simply setting the first qtd to a non zero value (i.e., the length of the QTD list). However, no bug occurred as the subsequent _buffer_fill_...() functions would overwrite the QTD list anyways. --- components/usb/hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/usb/hcd.c b/components/usb/hcd.c index 7aa13c7936..ac081a8cea 100644 --- a/components/usb/hcd.c +++ b/components/usb/hcd.c @@ -2343,7 +2343,7 @@ static inline void _buffer_parse_ctrl(dma_buffer_block_t *buffer) //Update URB status transfer->status = USB_TRANSFER_STATUS_COMPLETED; //Clear the descriptor list - memset(buffer->xfer_desc_list, XFER_LIST_LEN_CTRL, sizeof(usbh_ll_dma_qtd_t)); + memset(buffer->xfer_desc_list, 0, XFER_LIST_LEN_CTRL * sizeof(usbh_ll_dma_qtd_t)); } static inline void _buffer_parse_bulk(dma_buffer_block_t *buffer) @@ -2359,7 +2359,7 @@ static inline void _buffer_parse_bulk(dma_buffer_block_t *buffer) //Update URB's status transfer->status = USB_TRANSFER_STATUS_COMPLETED; //Clear the descriptor list - memset(buffer->xfer_desc_list, XFER_LIST_LEN_BULK, sizeof(usbh_ll_dma_qtd_t)); + memset(buffer->xfer_desc_list, 0, XFER_LIST_LEN_BULK * sizeof(usbh_ll_dma_qtd_t)); } static inline void _buffer_parse_intr(dma_buffer_block_t *buffer, bool is_in, int mps) @@ -2409,7 +2409,7 @@ static inline void _buffer_parse_intr(dma_buffer_block_t *buffer, bool is_in, in //Update URB's status transfer->status = USB_TRANSFER_STATUS_COMPLETED; //Clear the descriptor list - memset(buffer->xfer_desc_list, XFER_LIST_LEN_INTR, sizeof(usbh_ll_dma_qtd_t)); + memset(buffer->xfer_desc_list, 0, XFER_LIST_LEN_INTR * sizeof(usbh_ll_dma_qtd_t)); } static inline void _buffer_parse_isoc(dma_buffer_block_t *buffer, bool is_in)