media: lmedm04: Handle errors for lme2510_int_read

[ Upstream commit a2836d3fe220220ff8c495ca9722f89cea8a67e7 ]

Add check for the return value of usb_pipe_endpoint() and
usb_submit_urb() in order to catch the errors.

Fixes: 15e1ce3318 ("[media] lmedm04: Fix usb_submit_urb BOGUS urb xfer, pipe 1 != type 3 in interrupt urb")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Link: https://lore.kernel.org/r/20240521091042.1769684-1-nichen@iscas.ac.cn
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Chen Ni
2024-05-21 17:10:42 +08:00
committed by Greg Kroah-Hartman
parent 04e42c7eb3
commit fafd5f2dd7

View File

@@ -373,6 +373,7 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
struct dvb_usb_device *d = adap_to_d(adap); struct dvb_usb_device *d = adap_to_d(adap);
struct lme2510_state *lme_int = adap_to_priv(adap); struct lme2510_state *lme_int = adap_to_priv(adap);
struct usb_host_endpoint *ep; struct usb_host_endpoint *ep;
int ret;
lme_int->lme_urb = usb_alloc_urb(0, GFP_KERNEL); lme_int->lme_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -390,11 +391,20 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
/* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */ /* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */
ep = usb_pipe_endpoint(d->udev, lme_int->lme_urb->pipe); ep = usb_pipe_endpoint(d->udev, lme_int->lme_urb->pipe);
if (!ep) {
usb_free_urb(lme_int->lme_urb);
return -ENODEV;
}
if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK) if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK)
lme_int->lme_urb->pipe = usb_rcvbulkpipe(d->udev, 0xa); lme_int->lme_urb->pipe = usb_rcvbulkpipe(d->udev, 0xa);
usb_submit_urb(lme_int->lme_urb, GFP_KERNEL); ret = usb_submit_urb(lme_int->lme_urb, GFP_KERNEL);
if (ret) {
usb_free_urb(lme_int->lme_urb);
return ret;
}
info("INT Interrupt Service Started"); info("INT Interrupt Service Started");
return 0; return 0;