Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796286381; b=uyPMqR+27eI8czYtEE6ACLE3VJ+Wnqs35SE67975LbTHetO7QI4s/1GUBu7yP4Z09jUX 81B86QZr6HkR/71wGkvFy5QOfx5/REHgmnxudvudSocdqYS1pj+yYq5e3yISdf73rbJ+b UTJ0+CLycx6IUnyGhouzfXJnBIs5Chwudr4+iaYirfiX5WVSf3S6pUDACCBdKGOD5SvJi Y0wy6pgzoSTlUM5ajMUqktmCQCh3NPpaLKWE/yu3QW7jxptQUKKlauHpC8oCXNB1C1Nk5 1pR5+brTIK/3XhzVg8YGkuJMLvGpOQ90pFIDIVYHV2Lrhz+BKFColNRN0wPRyyL5vOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796286381; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=jOgIiSMPKgLnFFX+SBIKQLR067D/OXtYRfGGww5gYR4=; b=JUu3pYTP2/ekvUrkC6VJR+vFn1uXPsWXXyWqlxLaUWmR7/0h5uBdOH+rflQithmMNl8V QnhIovi0cOB3Rnmy4FUSF/EwpgwqRlc2O9tEaNjFKOko5vjPQT9bVsMG+3FQ44b6NVdv9 HZTVrP0QO2oHFNdGm+xpfL/Ss7yqx5f42RTmgN1jUqtoerdBJfXDNsxZZJqQVRqdKqD4/ /R86tUzOuvyavXvo6AA5SR6dqg4JsEUxyQ2VWwmlcVtLM28mMxaSoCW32vIpXZcy68TXb feBG6vuDs93fhZjpXOu9hGqeYTTUIURky82c9qi8Qr2vSpNV9gHGGEMhBJH77/UK6Jg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XOD1urdy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C99F606A33A; Thu, 3 Dec 2026 08:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XOD1urdy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A39C1F00896; Thu, 3 Dec 2026 08:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796286380; bh=jOgIiSMPKgLnFFX+SBIKQLR067D/OXtYRfGGww5gYR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XOD1urdyEpY6E7AZbZ37LXr1UmNrttPXuTjGj8d7/QEgtfA1l/SoFMGmC11QPBYKo sXcZ4FsZFvxj9nM9+aH6hkZX8rvQq9vKEFSC31Wc2WFAmYmyRbk6t7UyERnhi2Eewh HO6P0wPtZOOT0BBuS6meMYkLAworZz42a6j6eUu358N+0HPtuM5piuYmFB5bgA06SM fxrBoUj4MenSAeDjsV5Uoyn/OYsS2W0xg/HjeTQ0Ck6BTNV1RWp0WYPmwShjjnThhR H7H7kqGUwSSRN4tFvni54huzbUdSphLO3V8r3e1DBf2UpwFq4jCVw0SUUwNscfRO1M LVH7Nl9tgpvvQ== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Carlo Caione , Jerome Brunet , Kevin Hilman , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl , Neil Armstrong , Srinivas Kandagatla Subject: [PATCH 01/10] nvmem: meson-efuse: Reject negative or zero SMC size in meson_efuse_probe() Date: Thu, 3 Dec 2026 08:26:02 +0000 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit meson_sm_call() writes the signed Secure Monitor return value into its s32 output pointer and returns 0 whenever the command ID is valid. meson_efuse_probe() passes an unsigned int pointer to meson_sm_call() and only checks for a negative return value from meson_sm_call() itself. If firmware returns a negative SMC error code (such as SMCCC_RET_NOT_SUPPORTED), size wraps to a large unsigned value and is assigned to econfig->size. Change size to s32 and reject negative or zero values from SM_EFUSE_USER_MAX with -EINVAL. Fixes: ad855eae6caf ("nvmem: amlogic: Add Amlogic Meson EFUSE driver") Closes: https://sashiko.dev/#/bug/linux-0667e60b-53c5-4a5a-b9b4-bb6f8d7eb500 Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- Cc: Carlo Caione Cc: Jerome Brunet 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index d7f9ac99a212..e8f384098be5 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -51,7 +51,7 @@ static int meson_efuse_probe(struct platform_device *pdev) struct nvmem_device *nvmem; struct nvmem_config *econfig; struct clk *clk; - unsigned int size; + s32 size; struct device_node *sm_np __free(device_node) = of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0); @@ -68,7 +68,8 @@ static int meson_efuse_probe(struct platform_device *pdev) if (IS_ERR(clk)) return dev_err_probe(dev, PTR_ERR(clk), "failed to get efuse gate"); - if (meson_sm_call(fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) { + if (meson_sm_call(fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0 || + size <= 0) { dev_err(dev, "failed to get max user"); return -EINVAL; } -- 2.56.1.911.g883d8bcb20-goog