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

ivanhu ivan.hu at canonical.com
Wed Jul 24 06:41:25 UTC 2019



On 7/5/19 12:29 AM, 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 a null
> pointer check to avoid this.
> 
> Addresses-Coverity: ("Uninitialized pointer read")
> Fixes: 2a377d8ec8c3 ("acpi: method: add _PTC test")
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/acpi/method/method.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 67a54465..37f6068d 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -2538,12 +2538,12 @@ static void method_test_PTC_return(
>   		return;
>   
>   	for (i = 0; i < obj->Package.Count; i++) {
> -		ACPI_RESOURCE *resource;
> +		ACPI_RESOURCE *resource = NULL;
>   		ACPI_STATUS   status;
>   		ACPI_OBJECT *element_buf = &obj->Package.Elements[i];
>   
>   		status = AcpiBufferToResource(element_buf->Buffer.Pointer, element_buf->Buffer.Length, &resource);
> -		if (ACPI_FAILURE(status)) {
> +		if (ACPI_FAILURE(status) || !resource) {
>   			failed = true;
>   			fwts_failed(fw, LOG_LEVEL_HIGH,
>   				"Method_PTCBadElement",
> 

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



More information about the fwts-devel mailing list