]> git.hungrycats.org Git - linux/commitdiff
ACPI: EC: Abort address space access upon error
authorArmin Wolf <W_Armin@gmx.de>
Wed, 22 May 2024 21:36:48 +0000 (23:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:19 +0000 (09:53 +0200)
[ Upstream commit f6f172dc6a6d7775b2df6adfd1350700e9a847ec ]

When 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>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/acpi/ec.c

index 1cec29ab64ce8d4e73a2461078c1bc6c0d74fef8..b66e5971fd3d1b14e7217c88ee833b0f4e84883b 100644 (file)
@@ -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);