Skip to content

Commit ab3a9f2

Browse files
Qian Caigregkh
authored andcommitted
acpi/hmat: fix an uninitialized memory_target
The commit 665ac7e ("acpi/hmat: Register processor domain to its memory") introduced an uninitialized "struct memory_target" that could cause an incorrect branching. drivers/acpi/hmat/hmat.c:385:6: warning: variable 'target' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (p->flags & ACPI_HMAT_MEMORY_PD_VALID) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/acpi/hmat/hmat.c:392:6: note: uninitialized use occurs here if (target && p->flags & ACPI_HMAT_PROCESSOR_PD_VALID) { ^~~~~~ drivers/acpi/hmat/hmat.c:385:2: note: remove the 'if' if its condition is always true if (p->flags & ACPI_HMAT_MEMORY_PD_VALID) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/acpi/hmat/hmat.c:369:30: note: initialize the variable 'target' to silence this warning struct memory_target *target; ^ = NULL Signed-off-by: Qian Cai <[email protected]> Reviewed-by: Mukesh Ojha <[email protected]> Fixes: 665ac7e ("acpi/hmat: Register processor domain to its memory") Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 57f5cf6 commit ab3a9f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/acpi/hmat/hmat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static int __init hmat_parse_proximity_domain(union acpi_subtable_headers *heade
366366
const unsigned long end)
367367
{
368368
struct acpi_hmat_proximity_domain *p = (void *)header;
369-
struct memory_target *target;
369+
struct memory_target *target = NULL;
370370

371371
if (p->header.length != sizeof(*p)) {
372372
pr_notice("HMAT: Unexpected address range header length: %d\n",

0 commit comments

Comments
 (0)