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 09/11] drm/bridge: it6505: hold endpoint OF node reference while parsing it
Date: Wed, 22 Jul 2026 21:52:19 +0000	[thread overview]
Message-ID: <20260722215220.11AF51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <8a9ec00b8464f0dec0242792f7f9d990d33589a0.1784717129.git.daniel@makrotopia.org>

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

Pre-existing issues:
- [High] The local variable `link_frequencies` is used uninitialized if `of_property_read_variable_u64_array()` returns 0.
--

--- Patch [9]: [PATCH v5 09/11] drm/bridge: it6505: hold endpoint OF node reference while parsing it ---
commit a152f40f457f0c59599e70de71a80bcac957ec14
Author: Daniel Golle <daniel@makrotopia.org>
Subject: drm/bridge: it6505: hold endpoint OF node reference while parsing it

This commit fixes an issue where the device tree endpoint node reference
is dropped before parsing is complete, which can cause a use-after-free
race if the node is freed dynamically. It defers the of_node_put() calls
to execute only after all property parsing has finished.

> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index e9208d827ce3d..6f23203d5f2a6 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
[ ... ]
>  	ep = of_graph_get_endpoint_by_regs(np, 0, 0);
> -	of_node_put(ep);
>  
>  	if (ep) {
>  		len = of_property_read_variable_u64_array(ep,
>  							  "link-frequencies",
>  							  &link_frequencies, 0,
>  							  1);
>  		if (len >= 0) {
>  			do_div(link_frequencies, 1000);

[Severity: High]
This isn't a bug introduced by this patch, but there is a pre-existing issue
here in it6505_parse_dt(). If of_property_read_variable_u64_array() returns
0, does this code use an uninitialized link_frequencies stack variable?

The of_property_read_variable_u64_array() function is called with a minimum
size of 0. If the link-frequencies property in the device tree is empty or
less than 8 bytes long (such as a common syntax mistake where a 32-bit
integer is provided), the function computes the size as 0. It then returns
0 without modifying the link_frequencies output variable.

Because the subsequent check is "if (len >= 0)", it evaluates to true, and
do_div() will consume whatever garbage value happens to be on the stack.
Depending on the stack memory, this could result in incorrectly rejecting
valid display modes or causing unpredictable display pipeline failures.

Should this code check "if (len > 0)" instead to guarantee the variable was
actually populated before using it?

>  			it6505->max_dpi_pixel_clock = link_frequencies;
>  		} else {
>  			dev_err(dev, "error link frequencies, use default");
>  			*max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX;
>  		}
> +		of_node_put(ep);
>  	} else {
>  		dev_err(dev, "error endpoint, use default");
>  		*max_dpi_pixel_clock = DPI_PIXEL_CLK_MAX;

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

  reply	other threads:[~2026-07-22 21:52 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
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 [this message]
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=20260722215220.11AF51F000E9@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