diff mbox

cpu: maxfreq: free cpufreq on error

Message ID 1367879017-18967-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King May 6, 2013, 10:23 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997350, Resource leak.

Need to free cpufreq before we return.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/cpu/maxfreq/maxfreq.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alex Hung May 7, 2013, 3:46 a.m. UTC | #1
On 05/07/2013 06:23 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997350, Resource leak.
>
> Need to free cpufreq before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/maxfreq/maxfreq.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
> index b6fa38c..e8e6ffa 100644
> --- a/src/cpu/maxfreq/maxfreq.c
> +++ b/src/cpu/maxfreq/maxfreq.c
> @@ -108,6 +108,7 @@ static int maxfreq_test1(fwts_framework *fw)
>
>   	if (cpufreqs_read == 0) {
>   		fwts_skipped(fw, "Cannot read CPU frequencies from %s, this generally happens on AMD CPUs, skipping test.", CPU_INFO_PATH);
> +		free(cpufreq);
>   		return FWTS_SKIP;
>   	}
>
> @@ -116,6 +117,7 @@ static int maxfreq_test1(fwts_framework *fw)
>   			"CPUFreqNoPath",
>   			"No %s directory available: cannot test.",
>   			CPU_FREQ_PATH);
> +		free(cpufreq);
>   		return FWTS_ERROR;
>   	}
>
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu May 10, 2013, 8:55 a.m. UTC | #2
On 05/07/2013 06:23 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997350, Resource leak.
>
> Need to free cpufreq before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/maxfreq/maxfreq.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
> index b6fa38c..e8e6ffa 100644
> --- a/src/cpu/maxfreq/maxfreq.c
> +++ b/src/cpu/maxfreq/maxfreq.c
> @@ -108,6 +108,7 @@ static int maxfreq_test1(fwts_framework *fw)
>
>   	if (cpufreqs_read == 0) {
>   		fwts_skipped(fw, "Cannot read CPU frequencies from %s, this generally happens on AMD CPUs, skipping test.", CPU_INFO_PATH);
> +		free(cpufreq);
>   		return FWTS_SKIP;
>   	}
>
> @@ -116,6 +117,7 @@ static int maxfreq_test1(fwts_framework *fw)
>   			"CPUFreqNoPath",
>   			"No %s directory available: cannot test.",
>   			CPU_FREQ_PATH);
> +		free(cpufreq);
>   		return FWTS_ERROR;
>   	}
>
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
index b6fa38c..e8e6ffa 100644
--- a/src/cpu/maxfreq/maxfreq.c
+++ b/src/cpu/maxfreq/maxfreq.c
@@ -108,6 +108,7 @@  static int maxfreq_test1(fwts_framework *fw)
 
 	if (cpufreqs_read == 0) {
 		fwts_skipped(fw, "Cannot read CPU frequencies from %s, this generally happens on AMD CPUs, skipping test.", CPU_INFO_PATH);
+		free(cpufreq);
 		return FWTS_SKIP;
 	}
 
@@ -116,6 +117,7 @@  static int maxfreq_test1(fwts_framework *fw)
 			"CPUFreqNoPath",
 			"No %s directory available: cannot test.",
 			CPU_FREQ_PATH);
+		free(cpufreq);
 		return FWTS_ERROR;
 	}