diff mbox

acpi: lid: free gpe resources on error

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

Commit Message

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

Coverity CID #997265, Resource leak.

Need to free gpe resources before we return.

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

Comments

Alex Hung May 7, 2013, 5:58 a.m. UTC | #1
On 05/07/2013 06:52 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997265, Resource leak.
>
> Need to free gpe resources before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/lid/lid.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/src/acpi/lid/lid.c b/src/acpi/lid/lid.c
> index c8827af..9117fc8 100644
> --- a/src/acpi/lid/lid.c
> +++ b/src/acpi/lid/lid.c
> @@ -114,6 +114,7 @@ static int lid_test_state(fwts_framework *fw, int button)
>
>   	if ((fd = fwts_acpi_event_open()) < 0) {
>   		fwts_log_error(fw, "Cannot connect to acpid.");
> +		fwts_gpe_free(gpes_start, gpe_count);
>   		return FWTS_ERROR;
>   	}
>
> @@ -132,6 +133,8 @@ static int lid_test_state(fwts_framework *fw, int button)
>
>   	if ((gpe_count = fwts_gpe_read(&gpes_end)) == FWTS_ERROR) {
>   		fwts_log_error(fw, "Cannot read GPEs.");
> +		fwts_gpe_free(gpes_start, gpe_count);
> +		return FWTS_ERROR;
>   	}
>
>   	fwts_gpe_test(fw, gpes_start, gpes_end, gpe_count);
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu May 16, 2013, 2:28 a.m. UTC | #2
On 05/07/2013 06:52 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997265, Resource leak.
>
> Need to free gpe resources before we return.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/lid/lid.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/src/acpi/lid/lid.c b/src/acpi/lid/lid.c
> index c8827af..9117fc8 100644
> --- a/src/acpi/lid/lid.c
> +++ b/src/acpi/lid/lid.c
> @@ -114,6 +114,7 @@ static int lid_test_state(fwts_framework *fw, int button)
>
>   	if ((fd = fwts_acpi_event_open()) < 0) {
>   		fwts_log_error(fw, "Cannot connect to acpid.");
> +		fwts_gpe_free(gpes_start, gpe_count);
>   		return FWTS_ERROR;
>   	}
>
> @@ -132,6 +133,8 @@ static int lid_test_state(fwts_framework *fw, int button)
>
>   	if ((gpe_count = fwts_gpe_read(&gpes_end)) == FWTS_ERROR) {
>   		fwts_log_error(fw, "Cannot read GPEs.");
> +		fwts_gpe_free(gpes_start, gpe_count);
> +		return FWTS_ERROR;
>   	}
>
>   	fwts_gpe_test(fw, gpes_start, gpes_end, gpe_count);
>

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

Patch

diff --git a/src/acpi/lid/lid.c b/src/acpi/lid/lid.c
index c8827af..9117fc8 100644
--- a/src/acpi/lid/lid.c
+++ b/src/acpi/lid/lid.c
@@ -114,6 +114,7 @@  static int lid_test_state(fwts_framework *fw, int button)
 
 	if ((fd = fwts_acpi_event_open()) < 0) {
 		fwts_log_error(fw, "Cannot connect to acpid.");
+		fwts_gpe_free(gpes_start, gpe_count);
 		return FWTS_ERROR;
 	}
 
@@ -132,6 +133,8 @@  static int lid_test_state(fwts_framework *fw, int button)
 
 	if ((gpe_count = fwts_gpe_read(&gpes_end)) == FWTS_ERROR) {
 		fwts_log_error(fw, "Cannot read GPEs.");
+		fwts_gpe_free(gpes_start, gpe_count);
+		return FWTS_ERROR;
 	}
 
 	fwts_gpe_test(fw, gpes_start, gpes_end, gpe_count);