dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yudi Yang" <2000jedi@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/rockchip: analogix_dp: bound endpoint name formatting
Date: Tue, 01 Sep 2026 20:04:41 +0000	[thread overview]
Message-ID: <20260901200442.1F4701F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901195511.2761251-1-2000jedi@gmail.com>

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

Pre-existing issues:
- [High] Potential Use-After-Free when accessing `endpoint.local_node` after its reference count has been dropped.
--

commit fc6c7cf47483df3837bf09097a92c40c4a5aed65
Author: Yudi Yang <2000jedi@gmail.com>

drm/rockchip: analogix_dp: bound endpoint name formatting

This commit modifies rockchip_dp_drm_encoder_enable() to use snprintf()
instead of sprintf() when formatting a device tree path into a stack
buffer. This prevents potential buffer overflows from sufficiently long
device tree paths.

> diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> index 587e60232ec7c..efd5a98e80bd2 100644
> --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> @@ -241,10 +241,11 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
>  				of_graph_get_remote_port(endpoint.local_node);

[Severity: High]
This isn't a bug introduced by this patch, but does this code use
endpoint.local_node after its reference count has been dropped?

In rockchip_dp_drm_encoder_enable(), drm_of_encoder_active_endpoint() is
called, which internally calls of_graph_parse_endpoint(). This sets
endpoint->local_node without acquiring a reference and then explicitly
drops its reference by calling of_node_put(ep) before returning.

This leaves endpoint.local_node as a dangling pointer, which is then
passed to of_graph_get_remote_port() here (and earlier to
of_graph_get_remote_port_parent()). 

Could this result in a Use-After-Free if the device tree node is dynamically
freed?

>  
>  			of_property_read_u32(remote_port, "reg", &port_id);
> -			sprintf(name, "%s vp%d", remote_port_parent->full_name, port_id);
> +			snprintf(name, sizeof(name), "%s vp%d",
> +				 remote_port_parent->full_name, port_id);
>  		} else {
> -			sprintf(name, "%s %s",
> -				remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb");
> +			snprintf(name, sizeof(name), "%s %s",
> +				 remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb");
>  		}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901195511.2761251-1-2000jedi@gmail.com?part=1

  reply	other threads:[~2026-09-01 20:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 19:55 [PATCH] drm/rockchip: analogix_dp: bound endpoint name formatting Yudi Yang
2026-09-01 20:04 ` sashiko-bot [this message]
2026-09-03 14:12 ` Heiko Stuebner

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=20260901200442.1F4701F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=2000jedi@gmail.com \
    --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