Skip to contentSkip to conversation

media: flexcop-usb: fix endpoint sanity check

git:media_tree/master Mauro Carvalho Chehab 1 participant 1 message Feb 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: flexcop-usb: fix endpoint sanity check
Author:  Johan Hovold <[email protected]>
Date:    Fri Jan 3 17:35:08 2020 +0100

commit 1b976fc6d684 ("media: b2c2-flexcop-usb: add sanity checking") added an endpoint sanity check to address a NULL-pointer dereference on probe. Unfortunately the check was done on the current altsetting which was later changed.

Fix this by moving the sanity check to after the altsetting is changed.

Fixes 1b976fc6d684 ("media: b2c2-flexcop-usb: add sanity checking")
Cc Oliver Neukum <[email protected]>
Cc stable <[email protected]>
 drivers/media/usb/b2c2/flexcop-usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

---

drivers/media/usb/b2c2/flexcop-usb.c +3 -3
index 039963a7765b..198ddfb8d2b1 100644
@@ -511,6 +511,9 @@ static int flexcop_usb_init(struct flexcop_usb *fc_usb)
 		return ret;
 	}
 
+	if (fc_usb->uintf->cur_altsetting->desc.bNumEndpoints < 1)
+		return -ENODEV;
+
 	switch (fc_usb->udev->speed) {
 	case USB_SPEED_LOW:
 		err("cannot handle USB speed because it is too slow.");
@@ -544,9 +547,6 @@ static int flexcop_usb_probe(struct usb_interface *intf,
 	struct flexcop_device *fc = NULL;
 	int ret;
 
-	if (intf->cur_altsetting->desc.bNumEndpoints < 1)
-		return -ENODEV;
-
 	if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
 		err("out of memory\n");
 		return -ENOMEM;