All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liang He <windhl@126.com>
To: andrzej.hajda@intel.com, narmstrong@baylibre.com,
	robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com,
	jonas@kwiboo.se, airlied@linux.ie, daniel@ffwll.ch,
	dri-devel@lists.freedesktop.org, windhl@126.com
Subject: [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt()
Date: Thu,  7 Jul 2022 09:23:30 +0800	[thread overview]
Message-ID: <20220707012330.305646-1-windhl@126.com> (raw)

There are two refcount bugs in this funcion:

BUG-1: 'pdata->mipi_host_node' will be assigned a new reference with
of_graph_get_remote_node() which will increase the refcount of the
object, correspondingly, we should call of_node_put() for the old
reference stored in the 'pdata->mipi_host_node'.

BUG-2: of_graph_get_endpoint_by_regs() will also increase the refcount
of the object and its new reference will be assigned to local 'ep0', so
there should be a of_node_put() when 'ep0' is not used anymore.

Fixes: 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")
Fixes: fd0310b6fe7d ("drm/bridge: anx7625: add MIPI DPI input feature")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 53a5da6c49dd..f39b9be19eaf 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1624,6 +1624,7 @@ static int anx7625_parse_dt(struct device *dev,
 	anx7625_get_swing_setting(dev, pdata);
 
 	pdata->is_dpi = 1; /* default dpi mode */
+	of_node_put(pdata->mipi_host_node);
 	pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
 	if (!pdata->mipi_host_node) {
 		DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
@@ -1638,6 +1639,7 @@ static int anx7625_parse_dt(struct device *dev,
 			bus_type = 0;
 
 		mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
+		of_node_put(ep0);
 	}
 
 	if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
-- 
2.25.1


             reply	other threads:[~2022-07-07  1:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  1:23 Liang He [this message]
2022-07-18 11:54 ` [PATCH] drm:bridge:analogix: Fix refcount bugs in anx7625_parse_dt() Robert Foss
2022-07-18 11:55   ` Robert Foss
2022-07-18 11:57     ` Liang He
2022-07-18 11:56   ` Liang He
2022-07-18 13:35     ` Liang He
2022-07-18 15:00       ` Robert Foss

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=20220707012330.305646-1-windhl@126.com \
    --to=windhl@126.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=andrzej.hajda@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonas@kwiboo.se \
    --cc=narmstrong@baylibre.com \
    --cc=robert.foss@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.