From 85ced6f4745f529098cae38a5bd3144035a1318c Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Tue, 28 May 2024 10:35:03 +0200 Subject: [PATCH 1/2] usb: dwc3: gadget: fix crash in dwc3_gadget_giveback() If the ep0 stalls or request are dequeued when gagdet is stopped, the request dma may not be mapped yet and dwc3_flush_cache() may be called with a NULL pointer. Check req->request.dma before calling dwc3_flush_cache() and later the usb_gadget_unmap_request() functions since it means that usb_gadget_map_request() hasn't been called yet. Fixes: fd15b58c1a9 ("dwc3: flush cache only if there is a buffer attached to a request") Signed-off-by: Neil Armstrong Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20240528-topic-sm8x50-dwc3-gadget-crash-fix-v1-1-58434ab4b3d3@linaro.org Signed-off-by: Mattijs Korpershoek --- drivers/usb/dwc3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 39c19d94de1..7d6bcc2627f 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -249,7 +249,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, list_del(&req->list); req->trb = NULL; - if (req->request.length) + if (req->request.dma && req->request.length) dwc3_flush_cache((uintptr_t)req->request.dma, req->request.length); if (req->request.status == -EINPROGRESS) @@ -257,7 +257,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, if (dwc->ep0_bounced && dep->number == 0) dwc->ep0_bounced = false; - else + else if (req->request.dma) usb_gadget_unmap_request(&dwc->gadget, &req->request, req->direction); From 4339138a2086f8449b9356130cb6e97a81aa8679 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 4 Jun 2024 07:44:25 +0200 Subject: [PATCH 2/2] dfu: add missing dependency for SPI flash DFU driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building the SPI flash DFU driver fails if SPI flash support is missing. drivers/dfu/dfu_sf.c:123:29: error: ‘CONFIG_SF_DEFAULT_MODE’ undeclared (first use in this function); Add the missing dependency. Signed-off-by: Heinrich Schuchardt Reviewed-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20240604054425.105902-1-heinrich.schuchardt@canonical.com Signed-off-by: Mattijs Korpershoek --- drivers/dfu/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig index 0360d9da142..971204758aa 100644 --- a/drivers/dfu/Kconfig +++ b/drivers/dfu/Kconfig @@ -68,6 +68,7 @@ config DFU_RAM config DFU_SF bool "SPI flash back end for DFU" + depends on SPI_FLASH || DM_SPI_FLASH help This option enables using DFU to read and write to SPI flash based storage.