Patchwork cpu: cpufreq: fix leak of dir before we return

login
register
mail settings
Submitter Colin King
Date May 6, 2013, 9:33 p.m.
Message ID <1367876025-16073-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/241795/
State Accepted
Headers show

Comments

Colin King - May 6, 2013, 9:33 p.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997352, Resource leak.

Need to closedir before we return.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/cpu/cpufreq/cpufreq.c | 1 +
 1 file changed, 1 insertion(+)
Alex Hung - May 7, 2013, 3:03 a.m.
On 05/07/2013 05:33 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997352, Resource leak.
>
> Need to closedir before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 5133f51..df52100 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -495,6 +495,7 @@ static void do_sw_any_test(fwts_framework *fw)
>   	if (get_performance_repeat(fw, first_cpu_index, 5, GET_PERFORMANCE_MIN, &lowperf) != FWTS_OK) {
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM, "CPUFreqSW_ANYGetPerf",
>   			"Failed to get CPU performance.");
> +		closedir(dir);
>   		return;
>   	}
>   	lowperf = (100 * lowperf) / top_speed;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - May 9, 2013, 6:36 a.m.
On Tue, May 7, 2013 at 5:33 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997352, Resource leak.
>
> Need to closedir before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/cpufreq/cpufreq.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 5133f51..df52100 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -495,6 +495,7 @@ static void do_sw_any_test(fwts_framework *fw)
>         if (get_performance_repeat(fw, first_cpu_index, 5, GET_PERFORMANCE_MIN, &lowperf) != FWTS_OK) {
>                 fwts_failed(fw, LOG_LEVEL_MEDIUM, "CPUFreqSW_ANYGetPerf",
>                         "Failed to get CPU performance.");
> +               closedir(dir);
>                 return;
>         }
>         lowperf = (100 * lowperf) / top_speed;
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>>

Patch

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 5133f51..df52100 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -495,6 +495,7 @@  static void do_sw_any_test(fwts_framework *fw)
 	if (get_performance_repeat(fw, first_cpu_index, 5, GET_PERFORMANCE_MIN, &lowperf) != FWTS_OK) {
 		fwts_failed(fw, LOG_LEVEL_MEDIUM, "CPUFreqSW_ANYGetPerf",
 			"Failed to get CPU performance.");
+		closedir(dir);
 		return;
 	}
 	lowperf = (100 * lowperf) / top_speed;