summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorBryan Brattlof <bb@ti.com>2022-05-26 00:36:17 +0300
committerDaniel Lezcano <daniel.lezcano@linaro.org>2022-07-28 18:29:47 +0300
commit99a049aace3257cf7644c3bbf67cb1a655248cc2 (patch)
treed0bb3937888bb2f2224f69ad8353c32b389276d2 /drivers/thermal
parent4102c4042a33c682021683ec26c2dca3fd9d7cc2 (diff)
downloadlinux-99a049aace3257cf7644c3bbf67cb1a655248cc2.tar.xz
thermal/drivers/k3_j72xx_bandgap: Fix ref_table memory leak during probe
If an error occurs in the k3_j72xx_bandgap_probe() function the memory allocated to the 'ref_table' will not be released. Add a err_free_ref_table step to the error path to free 'ref_table' Fixes: 72b3fc61c752 ("thermal: k3_j72xx_bandgap: Add the bandgap driver support") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Bryan Brattlof <bb@ti.com> Reviewed-by: Keerthy <j-keerthy@ti.com> Link: https://lore.kernel.org/r/20220525213617.30002-1-bb@ti.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/k3_j72xx_bandgap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_bandgap.c
index 64e323158952..3a35aa38ff51 100644
--- a/drivers/thermal/k3_j72xx_bandgap.c
+++ b/drivers/thermal/k3_j72xx_bandgap.c
@@ -433,7 +433,7 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
GFP_KERNEL);
if (!derived_table) {
ret = -ENOMEM;
- goto err_alloc;
+ goto err_free_ref_table;
}
/* Workaround not needed if bit30/bit31 is set even for J721e */
@@ -483,7 +483,7 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
if (IS_ERR(ti_thermal)) {
dev_err(bgp->dev, "thermal zone device is NULL\n");
ret = PTR_ERR(ti_thermal);
- goto err_alloc;
+ goto err_free_ref_table;
}
}
@@ -514,6 +514,9 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
return 0;
+err_free_ref_table:
+ kfree(ref_table);
+
err_alloc:
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);