From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BB0B606A33A for ; Thu, 3 Dec 2026 08:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ohxYhbcg; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nZLrQLFJ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=Umy+MrdijDwZcWm4wVExPaz6cSm/w6GF8sXE/OEZJyU=; b=ohxYhbcgiGK0roFz0n+FyGVvdV pn+uTlIlB2+TzqYzRAWdlCDqtsne8SbpHM5mCiwtlHbUKTi1VcPp4Ie5oHdwrbhQG0CD1likQWtWu jG9LeQxWXY8H/nOkKdwpeTQ+METq9AHeU0/mlAsV+hjQ+KllaxVw+UvIOPYqoPylO8j5g+BaHnw0c +esnBG336TjomlmjW7bN4e0kQ5FrNFFAGrNUMI/E+UPUI5xhRjxI/gI7brYRS0RT8XfSlOKAVw2QS ht3LjQmIIJToGGG7gaep15p5iL+NzZnx5fOSkZMpfc3aPgx4+CTu37L6CxgwA7WmPcJVVNNjXOMeS 66IFDTZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ29H-0000000DqHy-1b9x; Thu, 03 Dec 2026 08:26:39 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ29D-0000000DqEU-2GRI; Thu, 03 Dec 2026 08:26:37 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id D523562225; Thu, 3 Dec 2026 08:26:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 715DC1F00893; Thu, 3 Dec 2026 08:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796286394; bh=cOKElgjvbLTIxE1aF6JMGcAxph+gY2e8OXsJv2FxiWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nZLrQLFJiBtx5MhzPweaBUIe4qDXQImHAlCALmzGHol7ik5R0ydeTYMZ8NPRYpU4l jzYC9lhj3b23IZC2ysFlSlyWULmK4Q/TIY9TJN3J/jhJ/KZBc67s99Ld0AibmVwfyR IuRj4Xp1mB1xFH9/0ZPF7z5ksKPvwIh5kH8snkDauCw/nCF0F2A9XP15in6l6i7COX CN6Fnu3SiGYP/Fz9YwqOiQjkEMwYHUFKCy1pmphKWlVhZt6/J2fnh3x7peP7rUYloI 00af9UHkvwQtu3PvwCTxsWtlhEp6ha5WO9rRy0w2lDLT708z/rnOmg6JcxgpkwFqA7 RYVO5gp4bVCWg== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Carlo Caione , Dan Carpenter , Greg Kroah-Hartman , Jerome Brunet , Joy Chakraborty , Kevin Hilman , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl , Neil Armstrong , Srinivas Kandagatla Subject: [PATCH 09/10] nvmem: meson-efuse: Detect short reads and writes from Secure Monitor Date: Thu, 3 Dec 2026 08:26:10 +0000 Message-ID: <320c7649745541c0954f2590db10bd186c3ccd75.1796286324.git.lee@kernel.org> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 --- Cc: Carlo Caione Cc: Dan Carpenter Cc: Greg Kroah-Hartman Cc: Jerome Brunet Cc: Joy Chakraborty Cc: Kevin Hilman Cc: linux-amlogic@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: Martin Blumenstingl Cc: Neil Armstrong Cc: Srinivas Kandagatla 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 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic