Patchwork acpi: s3: free quirks and command resources

login
register
mail settings
Submitter Colin King
Date May 6, 2013, 11 p.m.
Message ID <1367881244-20843-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/241814/
State Accepted
Headers show

Comments

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

Coverity CID #997264, Resource leak.

Need to free quirks and command before we return.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/s3/s3.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Colin King - May 7, 2013, 9:48 a.m.
On 07/05/13 00:00, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Coverity CID #997264, Resource leak.
> 
> Need to free quirks and command before we return.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/s3/s3.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
> index ae89423..7528ec2 100644
> --- a/src/acpi/s3/s3.c
> +++ b/src/acpi/s3/s3.c
> @@ -73,8 +73,8 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>  	int differences;
>  	time_t t_start;
>  	time_t t_end;
> -	char *command;
> -	char *quirks;
> +	char *command = NULL;
> +	char *quirks = NULL;
>  	char buffer[80];
>  
>  	fwts_klog_clear();
> @@ -183,6 +183,11 @@ static int s3_do_suspend_resume(fwts_framework *fw,
>  		fwts_tag_failed(fw, FWTS_TAG_POWER_MANAGEMENT);
>  	}
>  
> +	if (command)
> +		free(command);
> +	if (quirks)
> +		free(quirks);
> +
>  	return FWTS_OK;
>  }
>  
> 
Bad fix, please ignore

Patch

diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
index ae89423..7528ec2 100644
--- a/src/acpi/s3/s3.c
+++ b/src/acpi/s3/s3.c
@@ -73,8 +73,8 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 	int differences;
 	time_t t_start;
 	time_t t_end;
-	char *command;
-	char *quirks;
+	char *command = NULL;
+	char *quirks = NULL;
 	char buffer[80];
 
 	fwts_klog_clear();
@@ -183,6 +183,11 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 		fwts_tag_failed(fw, FWTS_TAG_POWER_MANAGEMENT);
 	}
 
+	if (command)
+		free(command);
+	if (quirks)
+		free(quirks);
+
 	return FWTS_OK;
 }