From: Myeonghun Pak <mhun512@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Ijae Kim <ae878000@gmail.com>,
Vasileios Almpanis <vasilisalmpanis@gmail.com>
Subject: [PATCH 4/4] usb: gadget: pch_udc: free the EP0 data descriptor to its owning pool
Date: Wed, 14 Oct 2026 23:49:16 -0400 [thread overview]
Message-ID: <20261015034916.2773248-5-mhun512@gmail.com> (raw)
In-Reply-To: <20261015034916.2773248-1-mhun512@gmail.com>
The EP0 OUT data descriptor is allocated from data_requests, but
cleanup destroys that pool before passing the descriptor to
stp_requests. Return it to data_requests before destroying the
owning pool. Keep the setup descriptor on stp_requests.
This issue was identified as part of our ongoing research while
reviewing kernel code.
Fixes: f646cf94520e ("USB device driver of Topcliff PCH")
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Compile-tested only.
drivers/usb/gadget/udc/pch_udc.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 38b9159e2461..b07da0fdcdfc 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -2984,20 +2984,21 @@ static void pch_udc_cleanup(struct pch_udc_dev *dev)
}
/* dma pool cleanup */
- dma_pool_destroy(dev->data_requests);
+ if (dev->data_requests) {
+ if (dev->ep[UDC_EP0OUT_IDX].td_data)
+ dma_pool_free(dev->data_requests,
+ dev->ep[UDC_EP0OUT_IDX].td_data,
+ dev->ep[UDC_EP0OUT_IDX].td_data_phys);
+ dma_pool_destroy(dev->data_requests);
+ }
if (dev->stp_requests) {
- /* cleanup DMA desc's for ep0in */
+ /* Free the EP0 OUT setup descriptor. */
if (dev->ep[UDC_EP0OUT_IDX].td_stp) {
dma_pool_free(dev->stp_requests,
dev->ep[UDC_EP0OUT_IDX].td_stp,
dev->ep[UDC_EP0OUT_IDX].td_stp_phys);
}
- if (dev->ep[UDC_EP0OUT_IDX].td_data) {
- dma_pool_free(dev->stp_requests,
- dev->ep[UDC_EP0OUT_IDX].td_data,
- dev->ep[UDC_EP0OUT_IDX].td_data_phys);
- }
dma_pool_destroy(dev->stp_requests);
}
prev parent reply other threads:[~2026-10-15 3:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 3:49 [PATCH 0/4] usb: gadget: pch_udc: order IRQ and descriptor lifetimes Myeonghun Pak
2026-10-15 3:49 ` [PATCH 1/4] usb: gadget: pch_udc: release IRQ handlers before DMA cleanup Myeonghun Pak
2026-10-15 3:49 ` [PATCH 2/4] usb: gadget: pch_udc: initialize DMA before registering interrupt sources Myeonghun Pak
2026-10-15 3:49 ` [PATCH 3/4] usb: gadget: pch_udc: track successful EP0 DMA mappings Myeonghun Pak
2026-10-15 3:49 ` Myeonghun Pak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015034916.2773248-5-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=vasilisalmpanis@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox