* [PATCH] drm/amdkfd: fix uninitialized variable use
@ 2018-03-15 16:49 Arnd Bergmann
2018-03-18 8:11 ` Oded Gabbay
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-03-15 16:49 UTC (permalink / raw)
To: Oded Gabbay, Alex Deucher, Christian König,
David (ChunMing) Zhou, David Airlie
Cc: Arnd Bergmann, Felix Kuehling, Harish Kasiviswanathan,
Kent Russell, Amber Lin, dri-devel, amd-gfx, linux-kernel
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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index 7493f47e7fe1..d85112224f1d 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -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;
--
2.9.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdkfd: fix uninitialized variable use
2018-03-15 16:49 [PATCH] drm/amdkfd: fix uninitialized variable use Arnd Bergmann
@ 2018-03-18 8:11 ` Oded Gabbay
0 siblings, 0 replies; 2+ messages in thread
From: Oded Gabbay @ 2018-03-18 8:11 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
David Airlie, Felix Kuehling, Harish Kasiviswanathan,
Kent Russell, Amber Lin, Maling list - DRI developers,
amd-gfx list, Linux-Kernel@Vger. Kernel. Org
On Thu, Mar 15, 2018 at 6:49 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> index 7493f47e7fe1..d85112224f1d 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> @@ -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;
> --
> 2.9.0
>
Thanks!
Applied to -next
Oded
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-18 8:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15 16:49 [PATCH] drm/amdkfd: fix uninitialized variable use Arnd Bergmann
2018-03-18 8:11 ` Oded Gabbay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®