]> asedeno.scripts.mit.edu Git - linux.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)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 7 Oct 2019 10:51:17 +0000 (07:51 -0300)
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>
drivers/media/usb/b2c2/flexcop-usb.c

index 1826ff825c2e7773d0a271aed67a2e512e611b0c..4bf85e9b78b815d687e5ecf3f247ad2c85df255f 100644 (file)
@@ -504,7 +504,13 @@ static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
 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.");