kernel: guard missing uvc ep desc

This commit is contained in:
Brad Stein 2026-01-27 01:13:09 -03:00
parent c7b06c4456
commit 1dc3bab3aa

View File

@ -52,7 +52,7 @@
for (i = 0; i < video->uvc_num_requests; i++) {
ureq = kzalloc(sizeof(struct uvc_request), GFP_KERNEL);
if (ureq == NULL)
@@ -764,20 +792,70 @@
@@ -764,20 +792,78 @@
{
int ret;
@ -74,6 +74,14 @@
return -ENODEV;
}
+ if (!video->ep->desc) {
+ uvcg_err(&video->uvc->func,
+ "Video enable failed, missing ep desc ep=%p maxpacket=%u maxburst=%u mult=%u\n",
+ video->ep, video->ep->maxpacket,
+ video->ep->maxburst, video->ep->mult);
+ return -EINVAL;
+ }
+
+ if (!video->kworker || !video->async_wq) {
+ uvcg_err(&video->uvc->func,
+ "Video enable failed, missing worker(s) kworker=%p async_wq=%p\n",
@ -125,7 +133,22 @@
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -362,10 +362,34 @@
@@ -298,6 +298,14 @@
int ret;
uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt);
+ uvcg_info(f,
+ "UVC set_alt: intf=%u alt=%u state=%u speed=%u ep=%p desc=%p maxpacket=%u maxburst=%u mult=%u\n",
+ interface, alt, uvc->state, cdev->gadget->speed,
+ uvc->video.ep,
+ uvc->video.ep ? uvc->video.ep->desc : NULL,
+ uvc->video.ep ? uvc->video.ep->maxpacket : 0,
+ uvc->video.ep ? uvc->video.ep->maxburst : 0,
+ uvc->video.ep ? uvc->video.ep->mult : 0);
if (interface == uvc->control_intf) {
if (alt)
@@ -362,10 +370,34 @@
return ret;
usb_ep_enable(uvc->video.ep);