From: Damon Ding <damon.ding@rock-chips•com>
To: hjc@rock-chips•com, heiko@sntech•de, andy.yan@rock-chips•com,
maarten.lankhorst@linux•intel.com, mripard@kernel•org,
tzimmermann@suse•de, airlied@gmail•com, simona@ffwll•ch,
robh@kernel•org, krzk+dt@kernel•org, conor+dt@kernel•org,
andrzej.hajda@intel•com, neil.armstrong@linaro•org,
rfoss@kernel•org
Cc: Laurent.pinchart@ideasonboard•com, jonas@kwiboo•se,
jernej.skrabec@gmail•com, nicolas.frattaroli@collabora•com,
cristian.ciocaltea@collabora•com,
sebastian.reichel@collabora•com,
dmitry.baryshkov@oss•qualcomm.com, luca.ceresoli@bootlin•com,
dianders@chromium•org, m.szyprowski@samsung•com,
dri-devel@lists•freedesktop.org, devicetree@vger•kernel.org,
linux-arm-kernel@lists•infradead.org,
linux-rockchip@lists•infradead.org, linux-kernel@vger•kernel.org,
Damon Ding <damon.ding@rock-chips•com>
Subject: [PATCH v10 06/11] drm/rockchip: analogix_dp: Fix OF node reference leak via auto cleanup
Date: Mon, 1 Jun 2026 14:50:55 +0800 [thread overview]
Message-ID: <20260601065100.1103873-7-damon.ding@rock-chips.com> (raw)
In-Reply-To: <20260601065100.1103873-1-damon.ding@rock-chips.com>
Sashiko reported a reference leak in rockchip_dp_drm_encoder_enable(),
the of_get_child_by_name() function does not call of_node_put() in a
symmetrical way [1].
Fix the device node reference leak by using __free(device_node) to
automatically manage of_node_put() for all device nodes.
Fixes: 729f8eefdcad ("drm/rockchip: analogix_dp: Add support for RK3588")
Link: https://sashiko.dev/#/patchset/20260527024336.191433-1-damon.ding@rock-chips.com?part=5 #1
Signed-off-by: Damon Ding <damon.ding@rock-chips•com>
---
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index d2af5eb29dbb..b1ed25cefe5e 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -8,6 +8,7 @@
* Jeff Chen <jeff.chen@rock-chips•com>
*/
+#include <linux/cleanup.h>
#include <linux/component.h>
#include <linux/mfd/syscon.h>
#include <linux/of.h>
@@ -206,7 +207,6 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state;
struct of_endpoint endpoint;
- struct device_node *remote_port, *remote_port_parent;
char name[32];
u32 port_id;
int ret;
@@ -230,18 +230,22 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
if (ret < 0)
return;
- remote_port_parent = of_graph_get_remote_port_parent(endpoint.local_node);
+ struct device_node *remote_port_parent __free(device_node) =
+ of_graph_get_remote_port_parent(endpoint.local_node);
if (remote_port_parent) {
- if (of_get_child_by_name(remote_port_parent, "ports")) {
- remote_port = of_graph_get_remote_port(endpoint.local_node);
+ struct device_node *ports __free(device_node) =
+ of_get_child_by_name(remote_port_parent, "ports");
+
+ if (ports) {
+ struct device_node *remote_port __free(device_node) =
+ of_graph_get_remote_port(endpoint.local_node);
+
of_property_read_u32(remote_port, "reg", &port_id);
- of_node_put(remote_port);
sprintf(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");
}
- of_node_put(remote_port_parent);
DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
}
--
2.34.1
next prev parent reply other threads:[~2026-06-01 6:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 6:50 [PATCH v10 00/11] Add eDP support for RK3576 Damon Ding
2026-06-01 6:50 ` [PATCH v10 01/11] dt-bindings: display: rockchip: analogix-dp: Fix hclk as third clock for RK3588 Damon Ding
2026-06-02 17:01 ` Conor Dooley
2026-06-01 6:50 ` [PATCH v10 02/11] dt-bindings: display: rockchip: analogix-dp: Add per-clock descriptions Damon Ding
2026-06-01 6:50 ` [PATCH v10 03/11] arm64: dts: rockchip: Add missing hclk for RK3588 eDP0 Damon Ding
2026-06-01 6:50 ` [PATCH v10 04/11] arm64: dts: rockchip: Add missing hclk for RK3588 eDP1 Damon Ding
2026-06-01 6:50 ` [PATCH v10 05/11] drm/rockchip: analogix_dp: Enable hclk for RK3588 Damon Ding
2026-06-01 6:50 ` Damon Ding [this message]
2026-06-01 6:50 ` [PATCH v10 07/11] dt-bindings: display: rockchip: analogix-dp: Add support for RK3576 Damon Ding
2026-06-01 6:50 ` [PATCH v10 08/11] arm64: dts: rockchip: Add eDP node " Damon Ding
2026-06-01 6:50 ` [PATCH v10 09/11] drm/bridge: analogix_dp: Rename and simplify is_rockchip() Damon Ding
2026-06-01 6:50 ` [PATCH v10 10/11] drm/bridge: analogix_dp: Add support for RK3576 Damon Ding
2026-06-01 6:51 ` [PATCH v10 11/11] drm/rockchip: " Damon Ding
2026-06-02 20:05 ` (subset) [PATCH v10 00/11] Add eDP " Heiko Stuebner
2026-06-02 20:41 ` 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=20260601065100.1103873-7-damon.ding@rock-chips.com \
--to=damon.ding@rock-chips$(echo .)com \
--cc=Laurent.pinchart@ideasonboard$(echo .)com \
--cc=airlied@gmail$(echo .)com \
--cc=andrzej.hajda@intel$(echo .)com \
--cc=andy.yan@rock-chips$(echo .)com \
--cc=conor+dt@kernel$(echo .)org \
--cc=cristian.ciocaltea@collabora$(echo .)com \
--cc=devicetree@vger$(echo .)kernel.org \
--cc=dianders@chromium$(echo .)org \
--cc=dmitry.baryshkov@oss$(echo .)qualcomm.com \
--cc=dri-devel@lists$(echo .)freedesktop.org \
--cc=heiko@sntech$(echo .)de \
--cc=hjc@rock-chips$(echo .)com \
--cc=jernej.skrabec@gmail$(echo .)com \
--cc=jonas@kwiboo$(echo .)se \
--cc=krzk+dt@kernel$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-rockchip@lists$(echo .)infradead.org \
--cc=luca.ceresoli@bootlin$(echo .)com \
--cc=m.szyprowski@samsung$(echo .)com \
--cc=maarten.lankhorst@linux$(echo .)intel.com \
--cc=mripard@kernel$(echo .)org \
--cc=neil.armstrong@linaro$(echo .)org \
--cc=nicolas.frattaroli@collabora$(echo .)com \
--cc=rfoss@kernel$(echo .)org \
--cc=robh@kernel$(echo .)org \
--cc=sebastian.reichel@collabora$(echo .)com \
--cc=simona@ffwll$(echo .)ch \
--cc=tzimmermann@suse$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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