summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2018-08-27 17:27:17 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2018-09-27 18:43:29 +0200
commit5f0be50f3f17738aa767984f0fd1d19e06c7e188 (patch)
tree7e35a10b648a6cf71ca4cd45adbfd28946a0c7ec
parent570911528badd8877fb4dba2a89aeef4af09c5b4 (diff)
soc: fix memory leak in probe
The consumer of nvmem_cell_read() is supposed to free the returned buffer. Use the SoC id early to simplify cleanup. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--drivers/soc/fsl/soc-vf610.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/soc/fsl/soc-vf610.c b/drivers/soc/fsl/soc-vf610.c
index 864bf5688f56..1db42c7442f6 100644
--- a/drivers/soc/fsl/soc-vf610.c
+++ b/drivers/soc/fsl/soc-vf610.c
@@ -46,6 +46,7 @@ static int vf610_soc_probe(struct platform_device *pdev)
u32 rom_rev;
u8 *socid1;
u8 *socid2;
+ char *socid;
int ret;
info = devm_kzalloc(dev, sizeof(struct vf610_soc), GFP_KERNEL);
@@ -72,11 +73,21 @@ static int vf610_soc_probe(struct platform_device *pdev)
if (IS_ERR(socid2)) {
dev_err(dev, "Could not read nvmem cell %ld\n",
PTR_ERR(socid2));
+ kfree(socid1);
return PTR_ERR(socid2);
}
add_device_randomness(socid1, id1_len);
add_device_randomness(socid2, id2_len);
+ socid = devm_kasprintf(dev, GFP_KERNEL,
+ "%02x%02x%02x%02x%02x%02x%02x%02x",
+ socid1[3], socid1[2], socid1[1], socid1[0],
+ socid2[3], socid2[2], socid2[1], socid2[0]);
+
+ kfree(socid1);
+ kfree(socid2);
+
+
soc_node = of_find_node_by_path("/soc");
if (soc_node == NULL)
return -ENODEV;
@@ -114,12 +125,7 @@ static int vf610_soc_probe(struct platform_device *pdev)
info->soc_dev_attr->machine = devm_kasprintf(dev,
GFP_KERNEL, "Freescale Vybrid");
- info->soc_dev_attr->soc_id = devm_kasprintf(dev,
- GFP_KERNEL,
- "%02x%02x%02x%02x%02x%02x%02x%02x",
- socid1[3], socid1[2], socid1[1],
- socid1[0], socid2[3], socid2[2],
- socid2[1], socid2[0]);
+ info->soc_dev_attr->soc_id = socid;
info->soc_dev_attr->family = devm_kasprintf(&pdev->dev,
GFP_KERNEL, "Freescale Vybrid VF%s",
soc_type);