Skip to contentSkip to conversation

usb: misc: usbio: Fix URB memory leak on submit failure

PATCH Superseded Felix Gu 2 participants 2 messages Mar 30

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Felix Gu

author
#0 lore raw

PATCH 1/1 usb: misc: usbio: Fix URB memory leak on submit failure

When usb_submit_urb() fails in usbio_probe(), the previously allocated URB is never freed, causing a memory leak.

Add usb_free_urb() call to properly release the URB on the error path.

Fixes 121a0f839dbb ("usb: misc: Add Intel USBIO bridge driver")
---
 drivers/usb/misc/usbio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/misc/usbio.c +3 -1
index 2e68d48a2cc0..d4eb3c7bafc4 100644
@@ -614,8 +614,10 @@ static int usbio_probe(struct usb_interface *intf, const struct usb_device_id *i
 	usb_fill_bulk_urb(usbio->urb, udev, usbio->rx_pipe, usbio->rxbuf,
 			  usbio->rxbuf_len, usbio_bulk_recv, usbio);
 	ret = usb_submit_urb(usbio->urb, GFP_KERNEL);
-	if (ret)
+	if (ret) {
+		usb_free_urb(usbio->urb);
 		return dev_err_probe(dev, ret, "Submitting usb urb\n");
+	}
 
 	mutex_lock(&usbio->ctrl_mutex);
 

---
base-commit: 3b058d1aeeeff27a7289529c4944291613b364e9
change-id: 20260330-usbio-d70e15c97a7a

Best regards,

Signature · 1 line
Felix Gu <[email protected]>
#1 lore raw
Quoted 4 lines · Felix Gu

When usb_submit_urb() fails in usbio_probe(), the previously allocated URB is never freed, causing a memory leak.

Add usb_free_urb() call to properly release the URB on the error path.

Hi,

the driver uses goto to unwind. Could you use the existing code with an additional label defined?

Regards
Oliver