Skip to contentSkip to conversation

acpi/osl: clear high bits in acpi_os_read_memory value

PATCH In review Paul Gortmaker 2 participants 2 messages Jul 7, 2014 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi/osl: clear high bits in acpi_os_read_memory value

If one looks at acpi_os_read_port() it is very similar to the acpi_os_read_memory() aside from the underlying I/O method. However we zero out the u32 in the former and not in the latter, when it seems prudent to do so in both.

This was found by quasi-random code inspection, and as such there is no known symptom or bug to associate with possibly having stale data in the high bits of "value".

---
 drivers/acpi/osl.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/osl.c +1 -0
index bad25b070fe0..a7373f1f31c8 100644
@@ -953,6 +953,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
 	if (!value)
 		value = &dummy;
 
+	*value = 0;
 	switch (width) {
 	case 8:
 		*(u8 *) value = readb(virt_addr);
Signature · 1 line
1.9.2
#1 lore raw
Quoted 8 lines · Paul Gortmaker

If one looks at acpi_os_read_port() it is very similar to the acpi_os_read_memory() aside from the underlying I/O method. However we zero out the u32 in the former and not in the latter, when it seems prudent to do so in both.

This was found by quasi-random code inspection, and as such there is no known symptom or bug to associate with possibly having stale data in the high bits of "value".

I'm actually afraid that this may lead to regressions, because the caller's intention may be to leave the higher bits untouched. So I'd think some audit of the existing callers would be necessary before making this change.

Quoted 18 lines
---
 drivers/acpi/osl.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/osl.c +1 -0
index bad25b070fe0..a7373f1f31c8 100644
@@ -953,6 +953,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
 	if (!value)
 		value = &dummy;
 
+	*value = 0;
 	switch (width) {
 	case 8:
 		*(u8 *) value = readb(virt_addr);
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.