[PATCH] ata: sata_dwc_460ex: Fix DMA channel leak in sata_dwc_port_start()

From: Haoxiang Li

Date: Tue Nov 17 2026 - 04:51:19 EST


If phy_power_on() fails in sata_dwc_port_start(), the error path
frees hsdevp without releasing the DMA channel acquired earlier.
Add a cleanup label to release the DMA channel before freeing
hsdevp on this failure path.

Fixes: 0f48debdb906 ("ata: sata_dwc_460ex: add phy support")
Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
---
drivers/ata/sata_dwc_460ex.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 486ea94a0184..c1025ab3e474 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -853,7 +853,7 @@ static int sata_dwc_port_start(struct ata_port *ap)

err = phy_power_on(hsdev->phy);
if (err)
- goto CLEANUP_ALLOC;
+ goto CLEANUP_DMA;

for (i = 0; i < SATA_DWC_QCMD_MAX; i++)
hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT;
@@ -880,6 +880,8 @@ static int sata_dwc_port_start(struct ata_port *ap)
dev_dbg(ap->dev, "%s: done\n", __func__);
return 0;

+CLEANUP_DMA:
+ dma_release_channel(hsdevp->chan);
CLEANUP_ALLOC:
kfree(hsdevp);
CLEANUP:
--
2.25.1