From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: Neill Kapron <nkapron@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: gadget: pch_udc: Fix potential ep0 DMA descriptor leak
Date: Wed, 11 Nov 2026 20:23:08 +0800 [thread overview]
Message-ID: <20261111-e5624093d6-usb-pch-udc@mail.sdu.edu.cn> (raw)
Removal destroys data_requests while the ep0 data descriptor is still
allocated, then tries to return that descriptor to stp_requests. The
busy data pool cannot release its DMA backing memory.
Return the descriptor to data_requests before destroying that pool.
This issue was found by our static analysis tool under development.
Fixes: f646cf94520e ("USB device driver of Topcliff PCH")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/usb/gadget/udc/pch_udc.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 99b3ce28210f..5996f1d16aed 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -2989,6 +2989,10 @@ static void pch_udc_remove(struct pci_dev *pdev)
dev_err(&pdev->dev,
"%s: gadget driver still bound!!!\n", __func__);
/* dma pool cleanup */
+ 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) {
@@ -2998,11 +3002,6 @@ static void pch_udc_remove(struct pci_dev *pdev)
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);
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
reply other threads:[~2026-11-11 12:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261111-e5624093d6-usb-pch-udc@mail.sdu.edu.cn \
--to=liguangshuo@mail.sdu.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.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
all inboxes | Powered by JetHome®