Patchwork acpica: fwts_acpica: missing unlock on error path

login
register
mail settings
Submitter Colin King
Date May 7, 2013, 8:28 a.m.
Message ID <1367915313-17171-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/242075/
State Accepted
Headers show

Comments

Colin King - May 7, 2013, 8:28 a.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997292: Missing unlock

Forgot to unlock mutex_lock_sem_table if we cannot find
any free semaphores on error path.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpica/fwts_acpica.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Alex Hung - May 9, 2013, 5:36 a.m.
On 05/07/2013 04:28 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997292: Missing unlock
>
> Forgot to unlock mutex_lock_sem_table if we cannot find
> any free semaphores on error path.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpica/fwts_acpica.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
> index 85ac735..73bfa73 100644
> --- a/src/acpica/fwts_acpica.c
> +++ b/src/acpica/fwts_acpica.c
> @@ -509,8 +509,10 @@ ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits,
>   		}
>   	}
>
> -	if (!sem)
> +	if (!sem) {
> +		pthread_mutex_unlock(&mutex_lock_sem_table);
>   		return AE_NO_MEMORY;
> +	}
>
>   	sem->used = true;
>   	sem->count = 0;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - May 20, 2013, 7:33 a.m.
On Tue, May 7, 2013 at 4:28 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997292: Missing unlock
>
> Forgot to unlock mutex_lock_sem_table if we cannot find
> any free semaphores on error path.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpica/fwts_acpica.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
> index 85ac735..73bfa73 100644
> --- a/src/acpica/fwts_acpica.c
> +++ b/src/acpica/fwts_acpica.c
> @@ -509,8 +509,10 @@ ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits,
>                 }
>         }
>
> -       if (!sem)
> +       if (!sem) {
> +               pthread_mutex_unlock(&mutex_lock_sem_table);
>                 return AE_NO_MEMORY;
> +       }
>
>         sem->used = true;
>         sem->count = 0;
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
index 85ac735..73bfa73 100644
--- a/src/acpica/fwts_acpica.c
+++ b/src/acpica/fwts_acpica.c
@@ -509,8 +509,10 @@  ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits,
 		}
 	}
 
-	if (!sem)
+	if (!sem) {
+		pthread_mutex_unlock(&mutex_lock_sem_table);
 		return AE_NO_MEMORY;
+	}
 
 	sem->used = true;
 	sem->count = 0;