Skip to contentSkip to conversation

gspca: Kill URBs on USB device disconnect

PATCH Superseded Ezequiel Garcia 1 participant 3 messages Feb 27, 2019 – Mar 24, 2019

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

PATCH 1/1 gspca: Kill URBs on USB device disconnect

In order to prevent ISOC URBs from being infinitely resubmitted, the driver's USB disconnect handler must kill all the in-flight URBs.

While here, change the URB packet status message to a debug level, to avoid spamming the console too much.

This commit fixes a lockup caused by an interrupt storm coming from the URB completion handler.

---
 drivers/media/usb/gspca/gspca.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/gspca/gspca.c +2 -1
index 9448ac0b8bc9..0510c20273aa 100644
@@ -294,7 +294,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
 		/* check the packet status and length */
 		st = urb->iso_frame_desc[i].status;
 		if (st) {
-			pr_err("ISOC data error: [%d] len=%d, status=%d\n",
+			gspca_dbg(gspca_dev, D_PACK, "ISOC data error: [%d] len=%d, status=%d\n",
 			       i, len, st);
 			gspca_dev->last_packet_type = DISCARD_PACKET;
 			continue;
@@ -1642,6 +1642,7 @@ void gspca_disconnect(struct usb_interface *intf)
 
 	mutex_lock(&gspca_dev->usb_lock);
 	gspca_dev->present = false;
+	destroy_urbs(gspca_dev);
 
 	vb2_queue_error(&gspca_dev->queue);
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 gspca: Kill URBs on USB device disconnect

In order to prevent ISOC URBs from being infinitely resubmitted, the driver's USB disconnect handler must kill all the in-flight URBs.

While here, change the URB packet status message to a debug level, to avoid spamming the console too much.

This commit fixes a lockup caused by an interrupt storm coming from the URB completion handler.

---
v2:
* Also kill the int URB.

 drivers/media/usb/gspca/gspca.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/gspca/gspca.c +3 -1
index 9448ac0b8bc9..4d7517411cc2 100644
@@ -294,7 +294,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
 		/* check the packet status and length */
 		st = urb->iso_frame_desc[i].status;
 		if (st) {
-			pr_err("ISOC data error: [%d] len=%d, status=%d\n",
+			gspca_dbg(gspca_dev, D_PACK, "ISOC data error: [%d] len=%d, status=%d\n",
 			       i, len, st);
 			gspca_dev->last_packet_type = DISCARD_PACKET;
 			continue;
@@ -1642,6 +1642,8 @@ void gspca_disconnect(struct usb_interface *intf)
 
 	mutex_lock(&gspca_dev->usb_lock);
 	gspca_dev->present = false;
+	destroy_urbs(gspca_dev);
+	gspca_input_destroy_urb(gspca_dev);
 
 	vb2_queue_error(&gspca_dev->queue);
 
Signature · 1 line
2.20.1
#2 lore raw
Quoted 6 lines · Ezequiel Garcia

In order to prevent ISOC URBs from being infinitely resubmitted, the driver's USB disconnect handler must kill all the in-flight URBs.

While here, change the URB packet status message to a debug level, to avoid spamming the console too much.

Quoted 8 lines

This commit fixes a lockup caused by an interrupt storm coming from the URB completion handler.

---
v2:
* Also kill the int URB.

Hans,

We still have to solve another race in this driver, but I think this fix is good to go.

Thanks,
Eze

Quoted 25 lines
 drivers/media/usb/gspca/gspca.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/gspca/gspca.c +3 -1
index 9448ac0b8bc9..4d7517411cc2 100644
@@ -294,7 +294,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
 		/* check the packet status and length */
 		st = urb->iso_frame_desc[i].status;
 		if (st) {
-			pr_err("ISOC data error: [%d] len=%d, status=%d\n",
+			gspca_dbg(gspca_dev, D_PACK, "ISOC data error: [%d] len=%d, status=%d\n",
 			       i, len, st);
 			gspca_dev->last_packet_type = DISCARD_PACKET;
 			continue;
@@ -1642,6 +1642,8 @@ void gspca_disconnect(struct usb_interface *intf)
 
 	mutex_lock(&gspca_dev->usb_lock);
 	gspca_dev->present = false;
+	destroy_urbs(gspca_dev);
+	gspca_input_destroy_urb(gspca_dev);
 
 	vb2_queue_error(&gspca_dev->queue);