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 v5 07/11] drm/bridge: it6505: avoid division by zero in audio FS debug print
Date: Wed, 22 Jul 2026 21:23:15 +0000	[thread overview]
Message-ID: <20260722212316.3EDA11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <699a55456c1eb21b450b01f9d55277f72ddf12d9.1784717129.git.daniel@makrotopia.org>

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

Pre-existing issues:
- [High] Missing I2C read error handling in `it6505_audio_input()` leads to logic reset and false positive audio enable.
--

--- Patch [7]: [PATCH v5 07/11] drm/bridge: it6505: avoid division by zero in audio FS debug print ---
commit ebf71cd14ba5699a1da0c18fc4c670be657e122d
Author: Daniel Golle <daniel@makrotopia.org>

drm/bridge: it6505: avoid division by zero in audio FS debug print

This commit adds a check for regbe > 0 before printing debug information
about the audio input frequency in it6505_enable_audio(). This prevents a
division by zero when regbe is 0 or negative due to an I2C read failure.

> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index fc95f8d4f4129..81d2c96445318 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -1622,8 +1622,11 @@ static void it6505_enable_audio(struct it6505 *it6505)
>  	it6505_set_bits(it6505, REG_AUDIO_SRC_CTRL, AUDIO_FIFO_RESET, 0x00);
>  	it6505_set_bits(it6505, REG_RESET_CTRL, AUDIO_RESET, 0x00);
>  	regbe = it6505_read(it6505, REG_AUDIO_INPUT_FREQ);

[Severity: High]
This is a pre-existing issue, but since we are handling I2C read failures
for REG_AUDIO_INPUT_FREQ here, I noticed a similar problem in
it6505_audio_input().

If it6505_read() fails, it returns a negative error code. In
it6505_audio_input():

	reg05 = it6505_read(it6505, REG_RESET_CTRL);
	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);

The negative error code in reg05 is stored without validation and passed
directly to it6505_write(). Because the regmap uses 8-bit values, the integer
is truncated (e.g., -5 becomes 0xFB). Will this inadvertently assert critical
hardware reset bits such as ALL_LOGIC_RESET and VIDEO_RESET?

Additionally, at the end of it6505_audio_input():

	return regbe != 0xFF;

Since regbe can be a negative error code if the second read fails, this check
evaluates to true. Could this falsely signal that audio should be enabled,
leading to unexpected behavior?

> -	DRM_DEV_DEBUG_DRIVER(dev, "regbe:0x%02x audio input fs: %d.%d kHz",
> -			     regbe, 6750 / regbe, (6750 % regbe) * 10 / regbe);
> +	if (regbe > 0)
> +		DRM_DEV_DEBUG_DRIVER(dev,
> +				     "regbe:0x%02x audio input fs: %d.%d kHz",
> +				     regbe, 6750 / regbe,
> +				     (6750 % regbe) * 10 / regbe);
>  	it6505_set_bits(it6505, REG_DATA_MUTE_CTRL, EN_AUD_MUTE, 0x00);
>  }

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

  reply	other threads:[~2026-07-22 21:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 15:45 [PATCH v5 00/11] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle
2026-07-22 15:45 ` [PATCH v5 01/11] drm/bridge: it6505: quiesce event sources and work on remove() Daniel Golle
2026-07-22 16:22   ` sashiko-bot
2026-07-22 15:45 ` [PATCH v5 02/11] drm/bridge: it6505: balance and disable runtime PM on remove Daniel Golle
2026-07-22 20:36   ` sashiko-bot
2026-07-22 15:45 ` [PATCH v5 03/11] drm/bridge: it6505: unregister DP AUX adapter on bridge detach Daniel Golle
2026-07-22 20:46   ` sashiko-bot
2026-07-22 15:46 ` [PATCH v5 04/11] drm/bridge: it6505: complete poweroff even if disabling regulators fails Daniel Golle
2026-07-22 20:58   ` sashiko-bot
2026-07-22 15:46 ` [PATCH v5 05/11] drm/bridge: it6505: bail out of the IRQ handler when status reads fail Daniel Golle
2026-07-22 15:46 ` [PATCH v5 06/11] drm/bridge: it6505: avoid division by zero in pixel clock calculation Daniel Golle
2026-07-22 15:46 ` [PATCH v5 07/11] drm/bridge: it6505: avoid division by zero in audio FS debug print Daniel Golle
2026-07-22 21:23   ` sashiko-bot [this message]
2026-07-22 15:47 ` [PATCH v5 08/11] drm/bridge: it6505: guard against zero channel count in audio infoframe Daniel Golle
2026-07-22 15:47 ` [PATCH v5 09/11] drm/bridge: it6505: hold endpoint OF node reference while parsing it Daniel Golle
2026-07-22 21:52   ` sashiko-bot
2026-07-22 15:47 ` [PATCH v5 10/11] drm/bridge: it6505: Add audio support Daniel Golle
2026-07-22 22:07   ` sashiko-bot
2026-07-22 15:47 ` [PATCH v5 11/11] 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=20260722212316.3EDA11F000E9@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