diff mbox series

[4/4] sata: dwc_ahsata: Fix memory issue in reset_sata

Message ID 20200503142703.14903-4-peng.fan@nxp.com
State New
Headers show
Series [1/4] sata: ahsata: Fix resource leak | expand

Commit Message

Peng Fan May 3, 2020, 2:27 p.m. UTC
From: Ye Li <ye.li at nxp.com>

The reset_sata should reset the sata device info and free the
probe_ent memory. Otherwise, it will cause memory leak if we
init the sata again.

Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/ata/dwc_ahsata.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Tom Rini May 8, 2020, 10:59 p.m. UTC | #1
On Sun, May 03, 2020 at 10:27:03PM +0800, Peng Fan wrote:

> From: Ye Li <ye.li at nxp.com>
> 
> The reset_sata should reset the sata device info and free the
> probe_ent memory. Otherwise, it will cause memory leak if we
> init the sata again.
> 
> Signed-off-by: Ye Li <ye.li at nxp.com>
> Signed-off-by: Peng Fan <peng.fan at nxp.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 82fbb50da6..2bc1de8b98 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -918,6 +918,9 @@  int reset_sata(int dev)
 	while (readl(&host_mmio->ghc) & SATA_HOST_GHC_HR)
 		udelay(100);
 
+	free(uc_priv);
+	memset(&sata_dev_desc[dev], 0, sizeof(struct blk_desc));
+
 	return 0;
 }