[PATCH 3/3] usb: max3421: Free transfer buffers on remove

From: Guangshuo Li

Date: Thu Sep 24 2026 - 07:26:14 EST


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@xxxxxxxxx>
---
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