* [PATCH] most: usb: fix memory leak on most_register_interface failure
@ 2026-06-17 8:37 Zhao Dongdong
0 siblings, 0 replies; only message in thread
From: Zhao Dongdong @ 2026-06-17 8:37 UTC (permalink / raw)
To: parthiban.veerasooran, christian.gromm; +Cc: linux-kernel, Zhao Dongdong
From: Zhao Dongdong <zhaodongdong@kylinos.cn>
In hdm_probe(), when most_register_interface() fails, the function returns
the error code directly without freeing the previously allocated memory
(mdev->busy_urbs, mdev->ep_address, mdev->cap, mdev->conf, and mdev).
Add an err_free_busy_urbs label and use goto to properly clean up all
allocated resources on failure.
Fixes: 97a6f772f36b ("drivers: most: add USB adapter driver")
Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
---
drivers/most/most_usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c
index 6437733afee0..c20901e1ce6c 100644
--- a/drivers/most/most_usb.c
+++ b/drivers/most/most_usb.c
@@ -1056,7 +1056,7 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
ret = most_register_interface(&mdev->iface);
if (ret)
- return ret;
+ goto err_free_busy_urbs;
mutex_lock(&mdev->io_mutex);
if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 ||
@@ -1084,6 +1084,8 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
mutex_unlock(&mdev->io_mutex);
return 0;
+err_free_busy_urbs:
+ kfree(mdev->busy_urbs);
err_free_ep_address:
kfree(mdev->ep_address);
err_free_cap:
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-17 8:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 8:37 [PATCH] most: usb: fix memory leak on most_register_interface failure Zhao Dongdong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox