ACK: [PATCH] acpi: method: add null pointer sanity checks on resource

Alex Hung alex.hung at canonical.com
Thu Jul 4 17:42:03 UTC 2019


On 2019-07-04 10:21 a.m., Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> The pointer resource could possibly be null or even a garbage
> value when it is dereferenced causing a segmentation fault, so
> be extra vigilent, nullify it to start with and add some null
> pointer checks to avoid this.
> 
> Addresses-Coverity: ("Uninitialized pointer read")
> Fixes: 6768f6248e95 ("acpi: method: refine _EVT test")
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/acpi/method/method.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 787e3438..67a54465 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -620,7 +620,7 @@ static void method_test_EVT_return (
>  	ACPI_OBJECT *obj,
>  	void *private)
>  {
> -	ACPI_RESOURCE *resource;
> +	ACPI_RESOURCE *resource = NULL;
>  	ACPI_STATUS   status;
>  
>  	FWTS_UNUSED(private);
> @@ -629,7 +629,7 @@ static void method_test_EVT_return (
>  		return;
>  
>  	status = AcpiBufferToResource(obj->Buffer.Pointer, obj->Buffer.Length, &resource);
> -	if (ACPI_FAILURE(status))
> +	if (ACPI_FAILURE(status) || !resource)
>  		return;
>  
>  	do {
> @@ -643,7 +643,7 @@ static void method_test_EVT_return (
>  				check_evt_event(fw, &resource->Data.Gpio);
>  
>  		resource = ACPI_NEXT_RESOURCE(resource);
> -	} while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG);
> +	} while (resource && resource->Type != ACPI_RESOURCE_TYPE_END_TAG);
>  }
>  
>  static int method_test_EVT(fwts_framework *fw)
> 

Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list