summaryrefslogtreecommitdiff
path: root/drivers/ata/dwc_ahsata.c
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2020-05-03 22:27:00 +0800
committerTom Rini <trini@konsulko.com>2020-05-08 18:29:00 -0400
commitbf38cbf9a289c41a0db6697c280ede73340191e7 (patch)
treef02561bcc569e45805b289ac4fa180fc251d2670 /drivers/ata/dwc_ahsata.c
parenta5e609b982a004e009e8ee0aa6066785db425ac2 (diff)
sata: ahsata: Fix resource leak
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> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/ata/dwc_ahsata.c')
-rw-r--r--drivers/ata/dwc_ahsata.c5
1 files changed, 5 insertions, 0 deletions
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;
}