All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] sata: ahsata: Fix resource leak
@ 2020-05-03 14:27 Peng Fan
  2020-05-03 14:27 ` [PATCH 2/4] sata: ahsata: Fix wrong operand for checking SERR DIAG_X Peng Fan
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Peng Fan @ 2020-05-03 14:27 UTC (permalink / raw)
  To: u-boot

From: Ye Li <ye.li@nxp.com>

Fix coverity issue CID 3606684: Resource leak (RESOURCE_LEAK)
leaked_storage: Variable uc_priv going out of scope leaks the storage it points to

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

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index c2e28fe518..a775214792 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -847,6 +847,9 @@ static int ahci_init_one(int pdev)
 	struct ahci_uc_priv *uc_priv = NULL;
 
 	uc_priv = malloc(sizeof(struct ahci_uc_priv));
+	if (!uc_priv)
+		return -ENOMEM;
+
 	memset(uc_priv, 0, sizeof(struct ahci_uc_priv));
 	uc_priv->dev = pdev;
 
@@ -871,6 +874,8 @@ static int ahci_init_one(int pdev)
 	return 0;
 
 err_out:
+	if (uc_priv)
+		free(uc_priv);
 	return rc;
 }
 
-- 
2.16.4

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

end of thread, other threads:[~2020-05-08 22:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 14:27 [PATCH 1/4] sata: ahsata: Fix resource leak Peng Fan
2020-05-03 14:27 ` [PATCH 2/4] sata: ahsata: Fix wrong operand for checking SERR DIAG_X Peng Fan
2020-05-04 14:17   ` Simon Glass
2020-05-08 22:59   ` Tom Rini
2020-05-03 14:27 ` [PATCH 3/4] sata: dwc_ahsata: Fix incorrect free Peng Fan
2020-05-04 14:17   ` Simon Glass
2020-05-08 22:59   ` Tom Rini
2020-05-03 14:27 ` [PATCH 4/4] sata: dwc_ahsata: Fix memory issue in reset_sata Peng Fan
2020-05-08 22:59   ` Tom Rini
2020-05-04 14:17 ` [PATCH 1/4] sata: ahsata: Fix resource leak Simon Glass
2020-05-04 14:28   ` Peng Fan
2020-05-08 22:59 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.