MLK-20240-1 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>
(cherry picked from commit 8f52ef83dbfc9f1c812b2166a7322a16efcbf939)
diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 8cac99e..9ef85b9 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -853,6 +853,9 @@
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;
@@ -877,6 +880,8 @@
return 0;
err_out:
+ if (uc_priv)
+ free(uc_priv);
return rc;
}