Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C3962F531B; Sat, 12 Sep 2026 13:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789219209; cv=none; b=Vx4yLtMxSBFxB12RwmPy187vxZgpJGzFa5pXt4dcZkfj5+EWDbfbhqTloVrIjWCas79kSgQQ69KSyNxi/Ji7SvA2bgq0afcVlc7o7WQoRh26rAyqygTK8/gz37/ichmqsz7Qm2+45iUkhlDsMPIBKMcXdCAZaKjeZjud7eQOsqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789219209; c=relaxed/simple; bh=agADPxyFO7iwrRX4HwoTXo9VPlHuL0xkARRiWeUs37s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRMFZ2plPbLwA509J9DfzRTdGw2++/WpWtiKnJLRWXWJv2MabCkheTgeSTUCiFYPt48mQjMWOuTeDdNVq2ZYtIRRpYeFaSRrjsEBX7a+cryXzN5Rc8N6MKPTIIlLTPYjqxC9Ba7solldgj5xEd8uWWqor13CrTLHFZq4JUAjfVQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FbS5DjHh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FbS5DjHh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B73291F000FF; Sat, 12 Sep 2026 13:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789219207; bh=mVDais0PixGO0aJosP88FtCmFH4Tm1VLz4Y4qhwkMKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FbS5DjHhPFYtWtiEILLBLLEl3gnzyNqUb0uBQtCjeCvx6ir1qrzNrFZcJqfQMqgyf Xvy8pw2xG74W1BE7zgfS4+ZTOXNPoTti4DO9gq3E7aKMUGUrEj4nG2gmZ/0kLrmH2A gxJAdYREF5Gl1EYJzUMfq60jEZEPrmj603QFPSzI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ruoyu Wang , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 6.12 1305/1376] tpm: st33zp24: Return zero on status read failure Date: Sat, 12 Sep 2026 09:02:11 +0200 Message-ID: <20260912065636.618666734@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ruoyu Wang [ Upstream commit 8b92687708f5ef980de01c2042dbd76d11f78547 ] st33zp24_status() ignores the result of the transport read and returns data even when no byte was received. The I2C transport, for example, skips i2c_master_recv() when the register-select write is short or fails, leaving data uninitialized. The resulting stack value can be interpreted as TPM_STS flags and let status checks complete spuriously. The status callback cannot propagate a transport error. Return zero unless recv() reports exactly one byte. With no status bits set, callers retry or take their existing timeout or error path instead of acting on an invalid status value. This issue was found by a static analysis checker and confirmed by manual source review. Fixes: 251a7b08213a ("TPM: STMicroelectronics ST33 I2C KERNEL 3.x") Signed-off-by: Ruoyu Wang Link: https://lore.kernel.org/r/20260813153032.3951878-1-ruoyuw560@gmail.com Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/st33zp24/st33zp24.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c index 06caf53a42ee5..ebb6f4ec54a22 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.c +++ b/drivers/char/tpm/st33zp24/st33zp24.c @@ -93,7 +93,9 @@ static u8 st33zp24_status(struct tpm_chip *chip) struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); u8 data; - tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1); + if (tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1) != 1) + return 0; + return data; } -- 2.53.0