Patchwork cpu: nx: free fwts_nx_cpuinfo on error

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

Comments

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

Coverity CID #997349, Resource leak.

Need to free fwts_nx_cpuinfo before we return.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/cpu/nx/nx.c | 1 +
 1 file changed, 1 insertion(+)
Alex Hung - May 7, 2013, 3:41 a.m.
On 05/07/2013 06:09 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997349, Resource leak.
>
> Need to free fwts_nx_cpuinfo before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/nx/nx.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/cpu/nx/nx.c b/src/cpu/nx/nx.c
> index 66ff2b9..9cf1da9 100644
> --- a/src/cpu/nx/nx.c
> +++ b/src/cpu/nx/nx.c
> @@ -153,6 +153,7 @@ static int nx_test3(fwts_framework *fw)
>   		}
>   		if (fwts_cpu_readmsr(i, 0x1a0, &val) != FWTS_OK) {
>   			fwts_log_error(fw, "Cannot read msr 0x1a0 on CPU%d", i);
> +			fwts_cpu_free_info(fwts_nx_cpuinfo);
>   			return FWTS_ERROR;
>   		}
>   		if (i == 0) {
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - May 10, 2013, 8:36 a.m.
On 05/07/2013 06:09 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997349, Resource leak.
>
> Need to free fwts_nx_cpuinfo before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/nx/nx.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/cpu/nx/nx.c b/src/cpu/nx/nx.c
> index 66ff2b9..9cf1da9 100644
> --- a/src/cpu/nx/nx.c
> +++ b/src/cpu/nx/nx.c
> @@ -153,6 +153,7 @@ static int nx_test3(fwts_framework *fw)
>   		}
>   		if (fwts_cpu_readmsr(i, 0x1a0, &val) != FWTS_OK) {
>   			fwts_log_error(fw, "Cannot read msr 0x1a0 on CPU%d", i);
> +			fwts_cpu_free_info(fwts_nx_cpuinfo);
>   			return FWTS_ERROR;
>   		}
>   		if (i == 0) {
>

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

Patch

diff --git a/src/cpu/nx/nx.c b/src/cpu/nx/nx.c
index 66ff2b9..9cf1da9 100644
--- a/src/cpu/nx/nx.c
+++ b/src/cpu/nx/nx.c
@@ -153,6 +153,7 @@  static int nx_test3(fwts_framework *fw)
 		}
 		if (fwts_cpu_readmsr(i, 0x1a0, &val) != FWTS_OK) {
 			fwts_log_error(fw, "Cannot read msr 0x1a0 on CPU%d", i);
+			fwts_cpu_free_info(fwts_nx_cpuinfo);
 			return FWTS_ERROR;
 		}
 		if (i == 0) {