Linux Tegra architecture development
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: host: balance resource lifetimes in host drivers
@ 2026-09-24 11:21 Guangshuo Li
  2026-09-24 11:21 ` [PATCH 1/3] usb: fhci: release IRQ and MMIO mappings on remove Guangshuo Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:21 UTC (permalink / raw)
  To: gregkh, mathias.nyman, thierry.reding, jonathanh
  Cc: linux-usb, linux-kernel, rosenp, kees, lgs201920130244,
	avorontsov, linux-tegra, jckuo, eeodqql09, stern, davidm

Several USB host drivers leave resources or references acquired in probe
unbalanced after the successful path.

Add the missing IRQ/MMIO, device-node, and buffer releases at the
corresponding lifetime endpoints, using existing probe cleanup as the
reference.

Guangshuo Li (3):
  usb: fhci: release IRQ and MMIO mappings on remove
  usb: xhci: tegra: release padctl node reference after probe
  usb: max3421: Free transfer buffers on remove

 drivers/usb/host/fhci-hcd.c    | 2 ++
 drivers/usb/host/max3421-hcd.c | 2 ++
 drivers/usb/host/xhci-tegra.c  | 1 +
 3 files changed, 5 insertions(+)


base-commit: f03c39de3a1307371a4032757cd1732e91087c7d
-- 
2.43.0


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

* [PATCH 1/3] usb: fhci: release IRQ and MMIO mappings on remove
  2026-09-24 11:21 [PATCH 0/3] usb: host: balance resource lifetimes in host drivers Guangshuo Li
@ 2026-09-24 11:21 ` Guangshuo Li
  2026-09-24 11:21 ` [PATCH 2/3] usb: xhci: tegra: release padctl node reference after probe Guangshuo Li
  2026-09-24 11:21 ` [PATCH 3/3] usb: max3421: Free transfer buffers on remove Guangshuo Li
  2 siblings, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:21 UTC (permalink / raw)
  To: gregkh, mathias.nyman, thierry.reding, jonathanh
  Cc: linux-usb, linux-kernel, rosenp, kees, lgs201920130244,
	avorontsov, linux-tegra, jckuo, eeodqql09, stern, davidm

of_fhci_probe() creates an IRQ mapping with irq_of_parse_and_map() and an
MMIO mapping with ioremap(). The probe error path releases both mappings,
but fhci_remove() omits the matching cleanup after a successful probe.

After usb_remove_hcd(), dispose hcd->irq with irq_dispose_mapping() and
unmap hcd->regs with iounmap() before usb_put_hcd(). This matches the
resource release order in the probe error path.

Fixes: 236dd4d18f29 ("USB: Driver for Freescale QUICC Engine USB Host Controller")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/usb/host/fhci-hcd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 71e785f445a3..1c8f6317f6aa 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -756,12 +756,14 @@ static void fhci_remove(struct device *dev)
 	int j;
 
 	usb_remove_hcd(hcd);
+	irq_dispose_mapping(hcd->irq);
 	free_irq(fhci->timer->irq, hcd);
 	gtm_put_timer16(fhci->timer);
 	cpm_muram_free(cpm_muram_offset(fhci->pram));
 	for (j = 0; j < NUM_PINS; j++)
 		qe_pin_free(fhci->pins[j]);
 	fhci_dfs_destroy(fhci);
+	iounmap(hcd->regs);
 	usb_put_hcd(hcd);
 }
 
-- 
2.43.0


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

* [PATCH 2/3] usb: xhci: tegra: release padctl node reference after probe
  2026-09-24 11:21 [PATCH 0/3] usb: host: balance resource lifetimes in host drivers Guangshuo Li
  2026-09-24 11:21 ` [PATCH 1/3] usb: fhci: release IRQ and MMIO mappings on remove Guangshuo Li
@ 2026-09-24 11:21 ` Guangshuo Li
  2026-09-24 11:21 ` [PATCH 3/3] usb: max3421: Free transfer buffers on remove Guangshuo Li
  2 siblings, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:21 UTC (permalink / raw)
  To: gregkh, mathias.nyman, thierry.reding, jonathanh
  Cc: linux-usb, linux-kernel, rosenp, kees, lgs201920130244,
	avorontsov, linux-tegra, jckuo, eeodqql09, stern, davidm

tegra_xusb_probe() obtains np with of_parse_phandle(), but the successful
path returns without the matching of_node_put(). The probe error path
already releases the reference through the put_padctl label.

Release np before returning from a successful probe so the node reference
is balanced once it is no longer needed.

Fixes: 971ee247060d ("usb: xhci: tegra: Enable ELPG for runtime/system PM")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/usb/host/xhci-tegra.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 6f235d1e117e..93e794b3343a 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1951,6 +1951,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)
 		pm_runtime_enable(tegra->dev);
 	}
 
+	of_node_put(np);
 	return 0;
 
 remove_usb3:
-- 
2.43.0


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

* [PATCH 3/3] usb: max3421: Free transfer buffers on remove
  2026-09-24 11:21 [PATCH 0/3] usb: host: balance resource lifetimes in host drivers Guangshuo Li
  2026-09-24 11:21 ` [PATCH 1/3] usb: fhci: release IRQ and MMIO mappings on remove Guangshuo Li
  2026-09-24 11:21 ` [PATCH 2/3] usb: xhci: tegra: release padctl node reference after probe Guangshuo Li
@ 2026-09-24 11:21 ` Guangshuo Li
  2 siblings, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-09-24 11:21 UTC (permalink / raw)
  To: gregkh, mathias.nyman, thierry.reding, jonathanh
  Cc: linux-usb, linux-kernel, rosenp, kees, lgs201920130244,
	avorontsov, linux-tegra, jckuo, eeodqql09, stern, davidm

max3421_probe() allocates max3421_hcd->tx and max3421_hcd->rx, but
max3421_remove() does not perform the matching kfree() calls after a
successful probe. The probe error path already releases both buffers.

Free the TX and RX buffers in max3421_remove() after stopping the SPI
thread and releasing the IRQ, before dropping the HCD reference.

Fixes: 2d53139f3162 ("Add support for using a MAX3421E chip as a host driver.")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/usb/host/max3421-hcd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 73e76d0e6973..994e8a07538d 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -1950,6 +1950,8 @@ max3421_remove(struct spi_device *spi)
 	spin_unlock_irqrestore(&max3421_hcd->lock, flags);
 
 	free_irq(spi->irq, hcd);
+	kfree(max3421_hcd->tx);
+	kfree(max3421_hcd->rx);
 
 	usb_put_hcd(hcd);
 }
-- 
2.43.0


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

end of thread, other threads:[~2026-09-24 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-24 11:21 [PATCH 0/3] usb: host: balance resource lifetimes in host drivers Guangshuo Li
2026-09-24 11:21 ` [PATCH 1/3] usb: fhci: release IRQ and MMIO mappings on remove Guangshuo Li
2026-09-24 11:21 ` [PATCH 2/3] usb: xhci: tegra: release padctl node reference after probe Guangshuo Li
2026-09-24 11:21 ` [PATCH 3/3] usb: max3421: Free transfer buffers on remove Guangshuo Li

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