[PATCH v2 01/13] platform/chrome: Correct LPC EC readmem bounds

From: Wang Yang

Date: Thu Dec 03 2026 - 23:21:36 EST


Reject offsets outside the EC memory map before calculating the
remaining space. Allow fixed-length reads ending exactly at the
end of the map and reject oversized reads without underflow.

Prepared with OpenAI Codex assistance.

Signed-off-by: Wang Yang <yang.wang@xxxxxxxxxxxxxxxx>
---
drivers/platform/chrome/cros_ec_lpc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 1e683e90a9df..4ddd3ca0effa 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -417,7 +417,7 @@ static int cros_ec_lpc_readmem(struct cros_ec_device *ec, unsigned int offset,
int cnt = 0;
int ret;

- if (offset >= EC_MEMMAP_SIZE - bytes)
+ if (offset >= EC_MEMMAP_SIZE || bytes > EC_MEMMAP_SIZE - offset)
return -EINVAL;

/* fixed length */
--
2.43.0