thermal: k3_j72xx_bandgap: Fix ref_table memory leak during probe
PATCH 1/1 thermal: 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'
--- drivers/thermal/k3_j72xx_bandgap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/thermal/k3_j72xx_bandgap.c +5 -2
@@ -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);
Signature · 1 line
2.17.1
Quoted 4 lines · Bryan Brattlof
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_tablestep to the error path to free 'ref_table'
Quoted 41 lines
Fixes 72b3fc61c752 ("thermal: k3_j72xx_bandgap: Add the bandgap driver support")Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Bryan Brattlof <[email protected]>--- drivers/thermal/k3_j72xx_bandgap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/thermal/k3_j72xx_bandgap.c +5
-2@@ -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);
[thermal: thermal/next] thermal/drivers/k3_j72xx_bandgap: Fix ref_table memory leak during probe
In reply to Bryan BrattlofThe following commit has been merged into the thermal/next branch of thermal:
The following commit has been merged into the thermal/next branch of thermal:
Commit-ID: 99a049aace3257cf7644c3bbf67cb1a655248cc2 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//99a049aace3257cf7644c3bbf67cb1a655248cc2 Author: Bryan Brattlof <[email protected]> AuthorDate: Wed, 25 May 2022 16:36:17 -05:00 Committer: Daniel Lezcano <[email protected]> CommitterDate: Thu, 28 Jul 2022 17:29:47 +02:00
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'
--- drivers/thermal/k3_j72xx_bandgap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/thermal/k3_j72xx_bandgap.c +5 -2
@@ -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);