tpm/tpm_ppi: Check return value of acpi_get_name
authorPeter Huewe <PeterHuewe@gmx.de>
Wed, 30 Oct 2013 00:40:28 +0000 (01:40 +0100)
committerPeter Huewe <peterhuewe@gmx.de>
Mon, 6 Jan 2014 13:37:23 +0000 (14:37 +0100)
If
 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
fails for whatever reason and does not return AE_OK
 if (strstr(buffer.pointer, context) != NULL) {
does dereference a null pointer.

-> Check the return value and return the status to the caller

Found by coverity
Cc: stable@vger.kernel.org
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
drivers/char/tpm/tpm_ppi.c

index 18c5810b646b11f6a8c8be035dfe1cc9c72df9f6..6ac9d275b73263a942ebe61dc296bcb4ae5f6185 100644 (file)
@@ -30,6 +30,9 @@ static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
        acpi_status status;
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+       if (ACPI_FAILURE(status))
+               return status;
+
        if (strstr(buffer.pointer, context) != NULL) {
                *return_value = handle;
                kfree(buffer.pointer);