Skip to contentSkip to conversation

drm/amdkfd: fix uninitialized variable use

PATCH In review Arnd Bergmann 2 participants 2 messages Mar 15, 2018 – Mar 18, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: fix uninitialized variable use

When CONFIG_ACPI is disabled, we never initialize the acpi_table structure in kfd_create_crat_image_virtual:

drivers/gpu/drm/amd/amdkfd/kfd_crat.c: In function 'kfd_create_crat_image_virtual':
drivers/gpu/drm/amd/amdkfd/kfd_crat.c:888:40: error: 'acpi_table' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The undefined behavior also happens for any other acpi_get_table() failure, but then the compiler can't warn about it.

This adds an error check that prevents the structure from being used in error, avoiding both the undefined behavior and the warning about it.

Fixes 520b8fb755cc ("drm/amdkfd: Add topology support for CPUs")
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1 -1
index 7493f47e7fe1..d85112224f1d 100644
@@ -882,7 +882,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
 	crat_table->length = sizeof(struct crat_header);
 
 	status = acpi_get_table("DSDT", 0, &acpi_table);
-	if (status == AE_NOT_FOUND)
+	if (status != AE_OK)
 		pr_warn("DSDT table not found for OEM information\n");
 	else {
 		crat_table->oem_revision = acpi_table->revision;
Signature · 6 lines
2.9.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 33 lines · Arnd Bergmann

When CONFIG_ACPI is disabled, we never initialize the acpi_table structure in kfd_create_crat_image_virtual:

drivers/gpu/drm/amd/amdkfd/kfd_crat.c: In function 'kfd_create_crat_image_virtual':
drivers/gpu/drm/amd/amdkfd/kfd_crat.c:888:40: error: 'acpi_table' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The undefined behavior also happens for any other acpi_get_table() failure, but then the compiler can't warn about it.

This adds an error check that prevents the structure from being used in error, avoiding both the undefined behavior and the warning about it.

Fixes 520b8fb755cc ("drm/amdkfd: Add topology support for CPUs")
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1 -2
index 7493f47e7fe1..d85112224f1d 100644
@@ -882,7 +882,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
        crat_table->length = sizeof(struct crat_header);
 
        status = acpi_get_table("DSDT", 0, &acpi_table);
-       if (status == AE_NOT_FOUND)
+       if (status != AE_OK)
                pr_warn("DSDT table not found for OEM information\n");
        else {
                crat_table->oem_revision = acpi_table->revision;
--
Quoted 2 lines

2.9.0

Thanks!
Applied to -next
Oded
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx