[PATCH] usb: misc: usbio: Fix URB memory leak on submit failure

Felix Gu posted 1 patch 1 day, 16 hours ago
There is a newer version of this series
drivers/usb/misc/usbio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] usb: misc: usbio: Fix URB memory leak on submit failure
Posted by Felix Gu 1 day, 16 hours ago
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 <ustc.gu@gmail.com>
---
 drivers/usb/misc/usbio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbio.c b/drivers/usb/misc/usbio.c
index 2e68d48a2cc0..d4eb3c7bafc4 100644
--- a/drivers/usb/misc/usbio.c
+++ b/drivers/usb/misc/usbio.c
@@ -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,
-- 
Felix Gu <ustc.gu@gmail.com>
Re: [PATCH] usb: misc: usbio: Fix URB memory leak on submit failure
Posted by Oliver Neukum 1 day, 14 hours ago
On 30.03.26 17:47, Felix Gu wrote:
> 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