]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: lmedm04: Handle errors for lme2510_int_read
authorChen Ni <nichen@iscas.ac.cn>
Tue, 21 May 2024 09:10:42 +0000 (17:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:46:54 +0000 (12:46 +0100)
[ Upstream commit a2836d3fe220220ff8c495ca9722f89cea8a67e7 ]

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

Fixes: 15e1ce33182d ("[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>
drivers/media/usb/dvb-usb-v2/lmedm04.c

index 0f5a1eed5ea9f89583a8b6ad71ec073f43917f34..b54eb5a083561bb0deeac2605bdebb0acc02e309 100644 (file)
@@ -372,6 +372,7 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
        struct dvb_usb_device *d = adap_to_d(adap);
        struct lme2510_state *lme_int = adap_to_priv(adap);
        struct usb_host_endpoint *ep;
+       int ret;
 
        lme_int->lme_urb = usb_alloc_urb(0, GFP_KERNEL);
 
@@ -389,11 +390,20 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap)
 
        /* Quirk of pipe reporting PIPE_BULK but behaves as interrupt */
        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)
                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");
 
        return 0;