Skip to contentSkip to conversation

drivers: usb: host: fix prevent memory leak in interrupt message submission

PATCH New [email protected] 1 participant 1 message May 16, 2025

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

PATCH 1/1 drivers: usb: host: fix prevent memory leak in interrupt message submission

From: Anton Moryakov <[email protected]>

Ensure int_queue is properly destroyed when receiving wrong buffer by adding error handling path. Fixes memory leak that occurred when backbuffer validation failed.

---
 drivers/usb/host/ehci-hcd.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/host/ehci-hcd.c +5 -0
index 7d5519c65a9..765d8b327ee 100644
@@ -1557,6 +1557,7 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe,
 		debug("got wrong buffer back (%p instead of %p)\n",
 		      backbuffer, buffer);
 		return -EINVAL;
+		goto err;
 	}
 
 	ret = _ehci_destroy_int_queue(dev, queue);
@@ -1565,6 +1566,10 @@ static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe,
 
 	/* everything worked out fine */
 	return result;
+	
+err:
+    _ehci_destroy_int_queue(dev, queue);  // Освобождаем очередь перед выходом
+    return result;
 }
 
 static int _ehci_lock_async(struct ehci_ctrl *ctrl, int lock)
Signature · 1 line
2.30.2