Skip to contentSkip to conversation

USB: wusbcore/wa-xfer: error handling fixes in setup_segs()

PATCH New Dan Carpenter 1 participant 1 message Feb 1, 2013

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

PATCH 1/1 USB: wusbcore/wa-xfer: error handling fixes in setup_segs()

1) It didn't free xfer->seg[0] so there was a leak.
2) xfer->seg[cnt] can be NULL.
3) Use usb_free_urb() for ->dto_urb instead of kfree().

drivers/usb/wusbcore/wa-xfer.c +3 -3
index 57c01ab..6ef94bc 100644
@@ -695,9 +695,9 @@ error_dto_alloc:
 	cnt--;
 error_seg_kzalloc:
 	/* use the fact that cnt is left at were it failed */
-	for (; cnt > 0; cnt--) {
-		if (xfer->is_inbound = 0)
-			kfree(xfer->seg[cnt]->dto_urb);
+	for (; cnt >= 0; cnt--) {
+		if (xfer->seg[cnt] && xfer->is_inbound = 0)
+			usb_free_urb(xfer->seg[cnt]->dto_urb);
 		kfree(xfer->seg[cnt]);
 	}
 error_segs_kzalloc: