Linux USB
 help / color / mirror / Atom feed
* [PATCH] xhci: dbc: Fix memory leak in xhci_alloc_dbc()
@ 2022-09-14  2:36 Rafael Mendonca
  2022-09-14 12:27 ` Mathias Nyman
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael Mendonca @ 2022-09-14  2:36 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman
  Cc: Rafael Mendonca, Mathias Nyman, linux-usb, linux-kernel

If DbC is already in use, then the allocated memory for the xhci_dbc struct
doesn't get freed before returning NULL, which leads to a memleak.

Fixes: 534675942e90 ("xhci: dbc: refactor xhci_dbc_init()")
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
---
 drivers/usb/host/xhci-dbgcap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index e61155fa6379..f1367b53b260 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -988,7 +988,7 @@ xhci_alloc_dbc(struct device *dev, void __iomem *base, const struct dbc_driver *
 	dbc->driver = driver;
 
 	if (readl(&dbc->regs->control) & DBC_CTRL_DBC_ENABLE)
-		return NULL;
+		goto err;
 
 	INIT_DELAYED_WORK(&dbc->event_work, xhci_dbc_handle_events);
 	spin_lock_init(&dbc->lock);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-14 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-14  2:36 [PATCH] xhci: dbc: Fix memory leak in xhci_alloc_dbc() Rafael Mendonca
2022-09-14 12:27 ` Mathias Nyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox