Patchwork acpi: method: check for NULL buf before dereferencing it (LP: #1205267)

login
register
mail settings
Submitter Colin King
Date July 26, 2013, 9:54 a.m.
Message ID <1374832467-6504-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/262104/
State Accepted
Headers show

Comments

Colin King - July 26, 2013, 9:54 a.m.
From: Colin Ian King <colin.king@canonical.com>

There may be a possibility that buf is NULL, so check for this
before dereferencing it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/method/method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - July 29, 2013, 8:14 a.m.
On 07/26/2013 05:54 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There may be a possibility that buf is NULL, so check for this
> before dereferencing it.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/method/method.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 628ead6..f46fdff 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -681,7 +681,7 @@ static void method_test_NULL_return(
>   		}
>   	}
>
> -	if (buf->Length && buf->Pointer) {
> +	if (buf && buf->Length && buf->Pointer) {
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodShouldReturnNothing", "%s returned values, but was expected to return nothing.", name);
>   		fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
>   		fwts_log_info(fw, "Object returned:");
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu - Aug. 1, 2013, 8:57 a.m.
On 07/26/2013 05:54 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There may be a possibility that buf is NULL, so check for this
> before dereferencing it.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/method/method.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 628ead6..f46fdff 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -681,7 +681,7 @@ static void method_test_NULL_return(
>   		}
>   	}
>
> -	if (buf->Length && buf->Pointer) {
> +	if (buf && buf->Length && buf->Pointer) {
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodShouldReturnNothing", "%s returned values, but was expected to return nothing.", name);
>   		fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
>   		fwts_log_info(fw, "Object returned:");
>

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

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 628ead6..f46fdff 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -681,7 +681,7 @@  static void method_test_NULL_return(
 		}
 	}
 
-	if (buf->Length && buf->Pointer) {
+	if (buf && buf->Length && buf->Pointer) {
 		fwts_failed(fw, LOG_LEVEL_MEDIUM, "MethodShouldReturnNothing", "%s returned values, but was expected to return nothing.", name);
 		fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN);
 		fwts_log_info(fw, "Object returned:");