From: sashiko-bot@kernel.org
To: "Ruoyu Wang" <ruoyuw560@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/bridge: tda998x: Handle short CEC register reads
Date: Fri, 14 Aug 2026 13:50:26 +0000 [thread overview]
Message-ID: <20260814135026.B5F541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814133952.1386158-1-ruoyuw560@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Dead code in `cec_enamods()` error check allows overwriting the register configuration when `cec_read()` fails.
--
--- Patch [1]: [PATCH] drm/bridge: tda998x: Handle short CEC register reads ---
commit 2bfd5ce7155e5841764b8ec506e16365cd7190b6
Author: Ruoyu Wang <ruoyuw560@gmail.com>
drm/bridge: tda998x: Handle short CEC register reads
This commit updates the error handling in cec_read() to ensure both messages
of the I2C transfer complete successfully before using the returned byte. If
the transfer is short or fails, it preserves the 0 fallback value to avoid
returning uninitialized stack memory.
> diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
> index 0b966c9844e70..fb414584962b7 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;
> }
>
> return val;
[Severity: High]
This is a pre-existing issue, but since cec_read() returns a u8, does the
error handling in callers like cec_enamods() work correctly?
For example, in drivers/gpu/drm/bridge/tda998x_drv.c:cec_enamods():
int val = cec_read(priv, REG_CEC_ENAMODS);
if (val < 0)
return;
if (enable)
val |= mods;
else
val &= ~mods;
cec_write(priv, REG_CEC_ENAMODS, val);
Because cec_read() returns an unsigned 8-bit integer, val will be
zero-extended and can never be negative. If a read fails due to an I2C error,
it returns 0, which bypasses the val < 0 check.
Could this result in writing back a modified 0 to REG_CEC_ENAMODS and
wiping out other enable bits, potentially causing the CEC module or clocks
to be disabled unexpectedly until a full reset occurs?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814133952.1386158-1-ruoyuw560@gmail.com?part=1
prev parent reply other threads:[~2026-08-14 13:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 13:39 [PATCH] drm/bridge: tda998x: Handle short CEC register reads Ruoyu Wang
2026-08-14 13:50 ` sashiko-bot [this message]
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=20260814135026.B5F541F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ruoyuw560@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 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.