Message ID | 20210930102717.15720-4-m.grzeschik@pengutronix.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | usb: gadget: uvc: smaller fixes for stability | expand |
Hi Michael, On Thu, Sep 30, 2021 at 12:27:13PM +0200, Michael Grzeschik wrote: > The reason that the ep_queue has failed could be an disabled endpoint. s/an/a/ > In that case it is not guaranteed that the ep->desc is still valid. > This patch adds an check for NULL. > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > drivers/usb/gadget/function/uvc_video.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c > index da93b46df464d..cdfd3726a86ae 100644 > --- a/drivers/usb/gadget/function/uvc_video.c > +++ b/drivers/usb/gadget/function/uvc_video.c > @@ -199,9 +199,11 @@ static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req) > uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n", > ret); > > - /* Isochronous endpoints can't be halted. */ > - if (usb_endpoint_xfer_bulk(video->ep->desc)) > - usb_ep_set_halt(video->ep); > + if (video->ep->desc) { > + /* Isochronous endpoints can't be halted. */ > + if (usb_endpoint_xfer_bulk(video->ep->desc)) > + usb_ep_set_halt(video->ep); > + } > } > > return ret; > -- > 2.30.2 >
Hi Michael, Thank you for the patch. On Thu, Sep 30, 2021 at 12:27:13PM +0200, Michael Grzeschik wrote: > The reason that the ep_queue has failed could be an disabled endpoint. s/an/a/ > In that case it is not guaranteed that the ep->desc is still valid. > This patch adds an check for NULL. s/an/a/ > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> > --- > drivers/usb/gadget/function/uvc_video.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c > index da93b46df464d..cdfd3726a86ae 100644 > --- a/drivers/usb/gadget/function/uvc_video.c > +++ b/drivers/usb/gadget/function/uvc_video.c > @@ -199,9 +199,11 @@ static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req) > uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n", > ret); > > - /* Isochronous endpoints can't be halted. */ > - if (usb_endpoint_xfer_bulk(video->ep->desc)) > - usb_ep_set_halt(video->ep); I'd add a comment here: /* If the endpoint is disabled the descriptor may be NULL. */ Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > + if (video->ep->desc) { > + /* Isochronous endpoints can't be halted. */ > + if (usb_endpoint_xfer_bulk(video->ep->desc)) > + usb_ep_set_halt(video->ep); > + } > } > > return ret;
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index da93b46df464d..cdfd3726a86ae 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -199,9 +199,11 @@ static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req) uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n", ret); - /* Isochronous endpoints can't be halted. */ - if (usb_endpoint_xfer_bulk(video->ep->desc)) - usb_ep_set_halt(video->ep); + if (video->ep->desc) { + /* Isochronous endpoints can't be halted. */ + if (usb_endpoint_xfer_bulk(video->ep->desc)) + usb_ep_set_halt(video->ep); + } } return ret;
The reason that the ep_queue has failed could be an disabled endpoint. In that case it is not guaranteed that the ep->desc is still valid. This patch adds an check for NULL. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> --- drivers/usb/gadget/function/uvc_video.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)