Chrome platform driver development
 help / color / mirror / Atom feed
From: "Wang Yang" <yang.wang@deepcomputing.io>
To: <linux-kernel@vger.kernel.org>
Cc: "Benson Leung" <bleung@chromium.org>,
	 "Tzung-Bi Shih" <tzungbi@kernel.org>,
	 "Guenter Roeck" <groeck@chromium.org>,
	<chrome-platform@lists.linux.dev>
Subject: [PATCH v2 01/13] platform/chrome: Correct LPC EC readmem bounds
Date: Fri,  4 Dec 2026 12:20:59 +0800	[thread overview]
Message-ID: <20261204042112.2985112-2-yang.wang@deepcomputing.io> (raw)
In-Reply-To: <20261204042112.2985112-1-yang.wang@deepcomputing.io>

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@deepcomputing.io>
---
 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

  reply	other threads:[~2026-12-04  4:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  4:20 [PATCH v2 00/13] Add SpacemiT K3 FML13V05 EC keyboard support Wang Yang
2026-12-04  4:20 ` Wang Yang [this message]
2026-12-04  4:21 ` [PATCH v2 02/13] platform/chrome: Extract LPC-style EC protocol helpers Wang Yang
2026-12-04  4:21 ` [PATCH v2 03/13] platform/chrome: Allow transport-specific LPC response timeouts Wang Yang
2026-12-04  4:21 ` [PATCH v2 04/13] platform/chrome: Allow transports to select EC IRQ flags Wang Yang
2026-12-04  4:21 ` [PATCH v2 05/13] dt-bindings: embedded-controller: Add SpacemiT K3 EC window Wang Yang
2026-12-04  4:21 ` [PATCH v2 08/13] platform/chrome: Allow ChromeOS platform support on RISC-V Wang Yang
2026-12-04  4:21 ` [PATCH v2 09/13] platform/chrome: Add SpacemiT K3 eSPI EC transport Wang Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204042112.2985112-2-yang.wang@deepcomputing.io \
    --to=yang.wang@deepcomputing.io \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tzungbi@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox