[PATCH] usbip: vudc: fix NULL pointer dereference in vep_dequeue()

From: raoxu

Date: Mon Jun 15 2026 - 05:37:58 EST


From: Xu Rao <raoxu@xxxxxxxxxxxxx>

vep_alloc_request() zero-initializes struct vrequest but never assigns
vrequest::udc. vep_dequeue() then reads that field and dereferences it
while checking udc->driver. Consequently, any usb_ep_dequeue() call that
reaches the vUDC dequeue operation can crash the kernel.

The endpoint passed to ->dequeue() identifies both the request queue
being searched and the owning vUDC. Derive the controller from that
endpoint with ep_to_vudc(), as the other endpoint operations do.

After this change, vrequest::udc has no users. Remove the redundant
controller backpointer.

Fixes: b6a0ca111867 ("usbip: vudc: Add UDC specific ops")
Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
---
drivers/usb/usbip/vudc.h | 1 -
drivers/usb/usbip/vudc_dev.c | 4 +---
2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
index faf61c9c6a98..5ef0e7d9b23a 100644
--- a/drivers/usb/usbip/vudc.h
+++ b/drivers/usb/usbip/vudc.h
@@ -38,7 +38,6 @@ struct vep {

struct vrequest {
struct usb_request req;
- struct vudc *udc;
struct list_head req_entry; /* Request queue */
};

diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index c5f079c5a1ea..5ef88117965d 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -333,7 +333,6 @@ static int vep_queue(struct usb_ep *_ep, struct usb_request *_req,
static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{
struct vep *ep;
- struct vrequest *req;
struct vudc *udc;
struct vrequest *lst;
unsigned long flags;
@@ -343,8 +342,7 @@ static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
return ret;

ep = to_vep(_ep);
- req = to_vrequest(_req);
- udc = req->udc;
+ udc = ep_to_vudc(ep);

if (!udc->driver)
return -ESHUTDOWN;
--
2.50.1