Skip to contentSkip to conversation

acpi: check if mapping is valid before reading / writing

PATCH In review Wei Liu 2 participants 2 messages Mar 1, 2017

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 2/2 acpi: check if mapping is valid before reading / writing

If acpi_map_os_memory has failed, return early with AE_ERROR.

Coverity-ID: 1401601
Coverity-ID: 1401602

---
Cc: Jan Beulich <[email protected]>

---
 xen/drivers/acpi/osl.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/drivers/acpi/osl.c +6 -0
index 94dbf0406f..9881db19da 100644
@@ -155,6 +155,9 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
 	u32 dummy;
 	void __iomem *virt_addr = acpi_os_map_memory(phys_addr, width >> 3);
 
+	if (!virt_addr)
+		return AE_ERROR;
+
 	if (!value)
 		value = &dummy;
 
@@ -182,6 +185,9 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
 {
 	void __iomem *virt_addr = acpi_os_map_memory(phys_addr, width >> 3);
 
+	if (!virt_addr)
+		return AE_ERROR;
+
 	switch (width) {
 	case 8:
 		writeb(value, virt_addr);
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel