All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: tda998x: Handle short CEC register reads
@ 2026-08-14 13:39 Ruoyu Wang
  2026-08-14 13:50 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-14 13:39 UTC (permalink / raw)
  To: Russell King, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Brian Starkey
  Cc: dri-devel, linux-kernel, Ruoyu Wang

cec_read() uses a two-message I2C transfer to select a register and read
its value. i2c_transfer() returns a negative errno or the number of
messages executed. A short transfer can therefore return zero or one
without writing the second message's buffer.

The current negative-only check treats that as success and returns an
uninitialized stack byte. The value may then affect register
read-modify-write operations, interrupt and HPD handling, or connector
detection.

Require both messages to complete before using the byte. Preserve the
existing zero fallback for failed reads.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: 14e5b5889d75 ("drm/i2c: tda998x: allow sharing of the CEC device accesses")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/gpu/drm/bridge/tda998x_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index 6c427bc75896b..7e82c918277fa 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -438,7 +438,7 @@ cec_read(struct tda998x_priv *priv, u8 addr)
 	int ret;
 
 	ret = i2c_transfer(priv->hdmi->adapter, msg, ARRAY_SIZE(msg));
-	if (ret < 0) {
+	if (ret != ARRAY_SIZE(msg)) {
 		dev_err(&priv->hdmi->dev, "Error %d reading from cec:0x%x\n",
 			ret, addr);
 		val = 0;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-14 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 13:39 [PATCH] drm/bridge: tda998x: Handle short CEC register reads Ruoyu Wang
2026-08-14 13:50 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.