From: Wentao Liang <vulab@iscas.ac.cn>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] drm/mipi-dsi: fix of_node reference leak in of_mipi_dsi_device_add error path
Date: Mon, 25 May 2026 04:50:28 +0000 [thread overview]
Message-ID: <20260525045028.3895931-1-vulab@iscas.ac.cn> (raw)
of_mipi_dsi_device_add() acquires an of_node reference via
of_node_get() before passing it to mipi_dsi_device_register_full().
However, when mipi_dsi_device_register_full() fails (e.g.,
mipi_dsi_device_add() returns an error), the acquired reference is
never released, causing the device_node to leak.
device_set_node() merely stores the fwnode pointer without taking
an additional refcount, so the reference from of_node_get() is the
only one the device holds on the success path. On the error path
the reference must be released by the caller that acquired it.
Fix this by checking the return value of
mipi_dsi_device_register_full() and calling of_node_put() on error.
Fixes: c63ae8a9686b ("drm/dsi: Use mipi_dsi_device_register_full() for DSI device creation")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/gpu/drm/drm_mipi_dsi.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 0390e14d3157..b54c10d92c57 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -163,6 +163,7 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
{
struct mipi_dsi_device_info info = { };
int ret;
+ struct mipi_dsi_device *dsi;
u32 reg;
if (of_alias_from_compatible(node, info.type, sizeof(info.type)) < 0) {
@@ -179,8 +180,10 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
info.channel = reg;
info.node = of_node_get(node);
-
- return mipi_dsi_device_register_full(host, &info);
+ dsi = mipi_dsi_device_register_full(host, &info);
+ if (IS_ERR(dsi))
+ of_node_put(node);
+ return dsi;
}
#else
static struct mipi_dsi_device *
--
2.34.1
next reply other threads:[~2026-05-25 4:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 4:50 Wentao Liang [this message]
2026-05-25 6:47 ` Claude review: drm/mipi-dsi: fix of_node reference leak in of_mipi_dsi_device_add error path Claude Code Review Bot
2026-05-25 6:47 ` Claude Code Review Bot
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=20260525045028.3895931-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
/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