mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPI: EC: Abort address space access upon error
@ 2024-05-22 21:36 Armin Wolf
  2024-05-22 21:36 ` [PATCH 2/2] ACPI: EC: Avoid returning AE_OK upon unknown error Armin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Armin Wolf @ 2024-05-22 21:36 UTC (permalink / raw)
  To: rafael, lenb; +Cc: linux-acpi, linux-kernel

Then a multi-byte address space access is requested, acpi_ec_read()/
acpi_ec_write() is being called multiple times.

Abort such operations if a single call to acpi_ec_read()/
acpi_ec_write() fails, as the data read from/written to the EC
might be incomplete.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/acpi/ec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e7793ee9e649..a68dce2147a4 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1333,10 +1333,13 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
 	if (ec->busy_polling || bits > 8)
 		acpi_ec_burst_enable(ec);

-	for (i = 0; i < bytes; ++i, ++address, ++value)
+	for (i = 0; i < bytes; ++i, ++address, ++value) {
 		result = (function == ACPI_READ) ?
 			acpi_ec_read(ec, address, value) :
 			acpi_ec_write(ec, address, *value);
+		if (result < 0)
+			break;
+	}

 	if (ec->busy_polling || bits > 8)
 		acpi_ec_burst_disable(ec);
--
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-27 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22 21:36 [PATCH 1/2] ACPI: EC: Abort address space access upon error Armin Wolf
2024-05-22 21:36 ` [PATCH 2/2] ACPI: EC: Avoid returning AE_OK upon unknown error Armin Wolf
2024-05-27 10:45   ` Rafael J. Wysocki

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®