[PATCH] acpi: battery: free gpe resources on error

Keng-Yu Lin kengyu at canonical.com
Mon May 20 17:51:55 UTC 2013


On Tue, May 7, 2013 at 6:30 AM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID #997269, Resource leak.
>
> Need to free gpe resources before we return.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/acpi/battery/battery.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/acpi/battery/battery.c b/src/acpi/battery/battery.c
> index 2fbc228..f83f086 100644
> --- a/src/acpi/battery/battery.c
> +++ b/src/acpi/battery/battery.c
> @@ -80,6 +80,7 @@ static int wait_for_acpi_event(fwts_framework *fw, char *name)
>
>         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;
>         }
>
> @@ -102,6 +103,8 @@ static int wait_for_acpi_event(fwts_framework *fw, char *name)
>
>         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);
> --
> 1.8.1.2
>

Acked-by: Keng-Yu Lin <kengyu at canonical.com>



More information about the fwts-devel mailing list