usb: misc: usbio: Fix URB memory leak on submit failure
Subsystems (2)
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")
Signed-off-by Felix Gu <[email protected]>
--- drivers/usb/misc/usbio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/misc/usbio.c +3 -1
@@ -614,8 +614,10 @@ static int usbio_probe(struct usb_interface *intf, const struct usb_device_id *iusb_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]>
Quoted 4 lines · Felix Gu
When
usb_submit_urb()fails inusbio_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