dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Golle" <daniel@makrotopia.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 11/13] drm/bridge: it6505: don't write an error code back to the reset register
Date: Sat, 25 Jul 2026 03:19:41 +0000	[thread overview]
Message-ID: <20260725031941.D1C461F000E9@smtp.kernel.org> (raw)
In-Reply-To: <e0e8ff86b0ac7f8d75cb254ebf6d22bcf79d2d34.1784947240.git.daniel@makrotopia.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing error check for it6505_read() inside it6505_aux_i2c_wait() causes I2C read failures to be silently truncated and falsely treated as successful AUX operations, populating caller buffers with error codes masquerading as valid data.
- [High] Blind restoration of the entire REG_RESET_CTRL register in it6505_audio_input() clobbers concurrent modifications made by other threads or workqueues.
--

--- Patch [11]: [PATCH v6 11/13] drm/bridge: it6505: don't write an error code back to the reset register ---
commit 6cdd627967e5d418a885e4cc00b3b1ef771660fc
Author: Daniel Golle <daniel@makrotopia.org>

drm/bridge: it6505: don't write an error code back to the reset register

This commit addresses an issue in it6505_audio_input() where a negative
error code from it6505_read() could be written back to the reset register.
It adds a check to return early if reading REG_RESET_CTRL fails, and also
ensures the audio input frequency readback is strictly positive.

> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 1678ec5b3ba70..aeaa7b5ecf5aa 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -1516,12 +1516,15 @@ static bool it6505_audio_input(struct it6505 *it6505)
>  	int reg05, regbe;
>  
>  	reg05 = it6505_read(it6505, REG_RESET_CTRL);
> +	if (reg05 < 0)
> +		return false;
> +
>  	it6505_set_bits(it6505, REG_RESET_CTRL, AUDIO_RESET, 0x00);
>  	usleep_range(3000, 4000);
>  	regbe = it6505_read(it6505, REG_AUDIO_INPUT_FREQ);
>  	it6505_write(it6505, REG_RESET_CTRL, reg05);

[Severity: High]
This is a pre-existing issue, but does this blind write back of the cached
reg05 value clobber concurrent modifications?

If this is called from the threaded IRQ handler or link_works, it can run
concurrently with the hdcp_work delayed workqueue. If hdcp_work clears
HDCP_RESET during the 3000-4000us sleep window, that concurrent change
will be permanently overwritten and lost when the stale reg05 value is
restored here.

> -	return regbe != 0xFF;
> +	return regbe > 0 && regbe != 0xFF;
>  }
>  
>  static void it6505_setup_audio_channel_status(struct it6505 *it6505)


While reviewing this fix for missing error checks, I noticed another similar
pre-existing issue in the same file:

[Severity: High]
This isn't a bug introduced by this patch, but does the lack of an error
check for it6505_read() inside it6505_aux_i2c_wait() cause I2C read failures
to be treated as successful operations?

drivers/gpu/drm/bridge/ite-it6505.c:it6505_aux_i2c_wait() {
    ...
    if (it6505_read(it6505, REG_AUX_USER_CTRL) & AUX_EVENT)
        break;
    ...
    *reply = it6505_read(it6505, REG_AUX_USER_REPLY) >> 4;
    ...
}

If it6505_read(it6505, REG_AUX_USER_CTRL) fails, it returns a negative errno
like -EIO (-5 = 0xFFFFFFFB). The bitwise check & AUX_EVENT (0x10) will
incorrectly evaluate to true, breaking the wait loop.

Then, if the read of REG_AUX_USER_REPLY also fails, the negative return is
right-shifted and truncated to 0xFF, which avoids error assignment and returns
success.

This eventually leads to it6505_aux_i2c_readb() reading garbage data into
the output buffer:

drivers/gpu/drm/bridge/ite-it6505.c:it6505_aux_i2c_readb() {
    ...
    buf[i] = it6505_read(it6505, REG_AUX_USER_RXB(0 + i));
    ...
}

Could this silently propagate hardware error codes to the DRM layer as valid
data?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784947240.git.daniel@makrotopia.org?part=11

  reply	other threads:[~2026-07-25  3:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25  2:57 [PATCH v6 00/13] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle
2026-07-25  2:58 ` [PATCH v6 01/13] drm/bridge: it6505: quiesce event sources and work on remove() Daniel Golle
2026-07-25  3:23   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 02/13] drm/bridge: it6505: balance and disable runtime PM on remove Daniel Golle
2026-07-25  3:18   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 03/13] drm/bridge: it6505: unregister DP AUX adapter on bridge detach Daniel Golle
2026-07-25  3:17   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 04/13] drm/bridge: it6505: complete poweroff even if disabling regulators fails Daniel Golle
2026-07-25  3:17   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 05/13] drm/bridge: it6505: bail out of the IRQ handler when status reads fail Daniel Golle
2026-07-25  2:59 ` [PATCH v6 06/13] drm/bridge: it6505: avoid division by zero in pixel clock calculation Daniel Golle
2026-07-25  3:20   ` sashiko-bot
2026-07-25  2:59 ` [PATCH v6 07/13] drm/bridge: it6505: avoid division by zero in audio FS debug print Daniel Golle
2026-07-25  3:16   ` sashiko-bot
2026-07-25  2:59 ` [PATCH v6 08/13] drm/bridge: it6505: guard against zero channel count in audio infoframe Daniel Golle
2026-07-25  3:00 ` [PATCH v6 09/13] drm/bridge: it6505: hold endpoint OF node reference while parsing it Daniel Golle
2026-07-25  3:15   ` sashiko-bot
2026-07-25  3:00 ` [PATCH v6 10/13] drm/bridge: it6505: reject a too short link-frequencies property Daniel Golle
2026-07-25  3:00 ` [PATCH v6 11/13] drm/bridge: it6505: don't write an error code back to the reset register Daniel Golle
2026-07-25  3:19   ` sashiko-bot [this message]
2026-07-25  3:01 ` [PATCH v6 12/13] drm/bridge: it6505: Add audio support Daniel Golle
2026-07-25  5:25   ` sashiko-bot
2026-07-25  3:01 ` [PATCH v6 13/13] drm/bridge: it6505: Don't reject audio hw_params without an encoder Daniel Golle

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=20260725031941.D1C461F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox