]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: flexcop-usb: fix NULL-ptr deref in flexcop_usb_transfer_init()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 24 Sep 2019 09:49:04 +0000 (06:49 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 31 Dec 2019 15:43:41 +0000 (16:43 +0100)
[ Upstream commit 649cd16c438f51d4cd777e71ca1f47f6e0c5e65d ]

If usb_set_interface() failed, iface->cur_altsetting will
not be assigned and it will be used in flexcop_usb_transfer_init()
It may lead a NULL pointer dereference.

Check usb_set_interface() return value in flexcop_usb_init()
and return failed to avoid using this NULL pointer.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/b2c2/flexcop-usb.c

index 1a801dc286f8567254516b579083eed3322c79f8..d1331f8281082d719b307dc52c8aa55f65ad75de 100644 (file)
@@ -504,7 +504,13 @@ urb_error:
 static int flexcop_usb_init(struct flexcop_usb *fc_usb)
 {
        /* use the alternate setting with the larges buffer */
-       usb_set_interface(fc_usb->udev,0,1);
+       int ret = usb_set_interface(fc_usb->udev, 0, 1);
+
+       if (ret) {
+               err("set interface failed.");
+               return ret;
+       }
+
        switch (fc_usb->udev->speed) {
        case USB_SPEED_LOW:
                err("cannot handle USB speed because it is too slow.");