All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal: k3_j72xx_bandgap: Fix ref_table memory leak during probe
@ 2022-05-25 21:36 Bryan Brattlof
  2022-05-26 14:58 ` J, KEERTHY
  2022-07-28 15:41 ` [thermal: thermal/next] thermal/drivers/k3_j72xx_bandgap: " thermal-bot for Bryan Brattlof
  0 siblings, 2 replies; 3+ messages in thread
From: Bryan Brattlof @ 2022-05-25 21:36 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui
  Cc: Keerthy, linux-pm, linux-kernel, 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_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>
---
 drivers/thermal/k3_j72xx_bandgap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_bandgap.c
index 64e3231589527..3a35aa38ff512 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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] thermal: k3_j72xx_bandgap: Fix ref_table memory leak during probe
  2022-05-25 21:36 [PATCH] thermal: k3_j72xx_bandgap: Fix ref_table memory leak during probe Bryan Brattlof
@ 2022-05-26 14:58 ` J, KEERTHY
  2022-07-28 15:41 ` [thermal: thermal/next] thermal/drivers/k3_j72xx_bandgap: " thermal-bot for Bryan Brattlof
  1 sibling, 0 replies; 3+ messages in thread
From: J, KEERTHY @ 2022-05-26 14:58 UTC (permalink / raw)
  To: Bryan Brattlof, Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria,
	Zhang Rui
  Cc: linux-pm, linux-kernel



On 5/26/2022 3:06 AM, Bryan Brattlof wrote:
> 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'

Reviewed-by: Keerthy <j-keerthy@ti.com>

> 
> 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>
> ---
>   drivers/thermal/k3_j72xx_bandgap.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_bandgap.c
> index 64e3231589527..3a35aa38ff512 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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [thermal: thermal/next] thermal/drivers/k3_j72xx_bandgap: Fix ref_table memory leak during probe
  2022-05-25 21:36 [PATCH] thermal: k3_j72xx_bandgap: Fix ref_table memory leak during probe Bryan Brattlof
  2022-05-26 14:58 ` J, KEERTHY
@ 2022-07-28 15:41 ` thermal-bot for Bryan Brattlof
  1 sibling, 0 replies; 3+ messages in thread
From: thermal-bot for Bryan Brattlof @ 2022-07-28 15:41 UTC (permalink / raw)
  To: linux-pm
  Cc: kernel test robot, Dan Carpenter, Bryan Brattlof, Keerthy,
	Daniel Lezcano, rui.zhang, amitk

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 <bb@ti.com>
AuthorDate:    Wed, 25 May 2022 16:36:17 -05:00
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
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'

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>
---
 drivers/thermal/k3_j72xx_bandgap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/k3_j72xx_bandgap.c b/drivers/thermal/k3_j72xx_bandgap.c
index 64e3231..3a35aa3 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);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-28 15:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 21:36 [PATCH] thermal: k3_j72xx_bandgap: Fix ref_table memory leak during probe Bryan Brattlof
2022-05-26 14:58 ` J, KEERTHY
2022-07-28 15:41 ` [thermal: thermal/next] thermal/drivers/k3_j72xx_bandgap: " thermal-bot for Bryan Brattlof

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.