thermal: cpu_cooling: small memory leak on error
diff mbox

Message ID 20141216235553.GG31467@mwanda
State Accepted
Delegated to: Eduardo Valentin
Headers show

Commit Message

Dan Carpenter Dec. 16, 2014, 11:55 p.m. UTC
There was a left over return here so the error handling isn't run.
It leads to a small memory leak and a static checker warning.

	drivers/thermal/cpu_cooling.c:351 __cpufreq_cooling_register()
	info: ignoring unreachable code.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Viresh Kumar Dec. 17, 2014, 5:26 a.m. UTC | #1
On Wed, Dec 17, 2014 at 5:25 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> There was a left over return here so the error handling isn't run.
> It leads to a small memory leak and a static checker warning.
>
>         drivers/thermal/cpu_cooling.c:351 __cpufreq_cooling_register()
>         info: ignoring unreachable code.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Fixes: f6859014c7e7 ("thermal: cpu_cooling: Store frequencies in
descending order")

>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 051eb48..9b45f64 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -347,7 +347,6 @@ __cpufreq_cooling_register(struct device_node *np,
>         cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
>                                           cpufreq_dev->max_level, GFP_KERNEL);
>         if (!cpufreq_dev->freq_table) {
> -               return ERR_PTR(-ENOMEM);
>                 cool_dev = ERR_PTR(-ENOMEM);
>                 goto free_cdev;
>         }

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 051eb48..9b45f64 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -347,7 +347,6 @@  __cpufreq_cooling_register(struct device_node *np,
 	cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
 					  cpufreq_dev->max_level, GFP_KERNEL);
 	if (!cpufreq_dev->freq_table) {
-		return ERR_PTR(-ENOMEM);
 		cool_dev = ERR_PTR(-ENOMEM);
 		goto free_cdev;
 	}