Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Carlo Caione <carlo@endlessm.com>,
	Dan Carpenter <error27@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Joy Chakraborty <joychakr@google.com>,
	Kevin Hilman <khilman@baylibre.com>,
	linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 09/10] nvmem: meson-efuse: Detect short reads and writes from Secure Monitor
Date: Thu,  3 Dec 2026 08:26:10 +0000	[thread overview]
Message-ID: <320c7649745541c0954f2590db10bd186c3ccd75.1796286324.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796286324.git.lee@kernel.org>

meson_efuse_read() and meson_efuse_write() treat any non-negative byte
count returned by meson_sm_call_read() or meson_sm_call_write() as
success and return 0, silently hiding partial reads or writes.

Return -EIO when meson_sm_call_write() reports a byte count other than
bytes, or when meson_sm_call_read() returns a non-zero byte count that
does not match bytes (preserving the 0 return convention documented by
meson_sm_call_read()).

Fixes: 7a0a6d0a7c80 ("nvmem: meson-efuse: Fix return value of nvmem callbacks")
Closes: https://sashiko.dev/#/bug/linux-990a1e10-e629-4b29-956e-2b2d39ac8f4a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Carlo Caione <carlo@endlessm.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Joy Chakraborty <joychakr@google.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Srinivas Kandagatla <srini@kernel.org>

 drivers/nvmem/meson-efuse.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
index e8f384098be5..383ee9281693 100644
--- a/drivers/nvmem/meson-efuse.c
+++ b/drivers/nvmem/meson-efuse.c
@@ -22,8 +22,12 @@ static int meson_efuse_read(void *context, unsigned int offset,
 
 	ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
 				 bytes, 0, 0, 0);
+	if (ret < 0)
+		return ret;
+	if (ret && ret != bytes)
+		return -EIO;
 
-	return ret < 0 ? ret : 0;
+	return 0;
 }
 
 static int meson_efuse_write(void *context, unsigned int offset,
@@ -34,8 +38,12 @@ static int meson_efuse_write(void *context, unsigned int offset,
 
 	ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
 				  bytes, 0, 0, 0);
+	if (ret < 0)
+		return ret;
+	if (ret != bytes)
+		return -EIO;
 
-	return ret < 0 ? ret : 0;
+	return 0;
 }
 
 static const struct of_device_id meson_efuse_match[] = {
-- 
2.56.1.911.g883d8bcb20-goog



  parent reply	other threads:[~2026-12-03  8:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  8:26 [PATCH 00/10] nvmem: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03  8:26 ` [PATCH 01/10] nvmem: meson-efuse: Reject negative or zero SMC size in meson_efuse_probe() Lee Jones
2026-12-03  8:26 ` Lee Jones [this message]
2026-12-03  8:26 ` [PATCH 10/10] nvmem: stm32: Avoid OP-TEE session leak on unaligned writes Lee Jones

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=320c7649745541c0954f2590db10bd186c3ccd75.1796286324.git.lee@kernel.org \
    --to=lee@kernel.org \
    --cc=carlo@endlessm.com \
    --cc=error27@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbrunet@baylibre.com \
    --cc=joychakr@google.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=srini@kernel.org \
    --cc=stable@vger.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