The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jernej Skrabec <jernej.skrabec@siol.net>
To: maxime.ripard@bootlin.com, wens@csie.org, robh+dt@kernel.org
Cc: airlied@linux.ie, mark.rutland@arm.com,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com
Subject: [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search
Date: Fri,  6 Jul 2018 19:51:03 +0200	[thread overview]
Message-ID: <20180706175113.26698-8-jernej.skrabec@siol.net> (raw)
In-Reply-To: <20180706175113.26698-1-jernej.skrabec@siol.net>

If error happens in sun8i_dw_hdmi_find_possible_crtcs(), nodes are not
released with of_node_put() before returning.

Fix that by calling of_node_put() when necessary. While on it, clean up
the code by using of_graph_get_remote_node() which also lowers number of
cases where error handling has to be performed.

Fixes: 57e23de02f48 ("drm/sun4i: DW HDMI: Expand algorithm for possible crtcs")

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---
 drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
index 3459b9ec56c9..21dc9ebad0b4 100644
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
@@ -53,22 +53,14 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
 	struct device_node *port, *ep, *remote, *remote_port;
 	u32 crtcs = 0;
 
-	port = of_graph_get_port_by_id(node, 0);
-	if (!port)
-		return 0;
-
-	ep = of_get_next_available_child(port, NULL);
-	if (!ep)
-		return 0;
-
-	remote = of_graph_get_remote_port_parent(ep);
+	remote = of_graph_get_remote_node(node, 0, -1);
 	if (!remote)
 		return 0;
 
 	if (sun8i_dw_hdmi_node_is_tcon_top(remote)) {
 		port = of_graph_get_port_by_id(remote, 4);
 		if (!port)
-			return 0;
+			goto crtcs_exit;
 
 		for_each_child_of_node(port, ep) {
 			remote_port = of_graph_get_remote_port(ep);
@@ -81,6 +73,9 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
 		crtcs = drm_of_find_possible_crtcs(drm, node);
 	}
 
+crtcs_exit:
+	of_node_put(remote);
+
 	return crtcs;
 }
 
-- 
2.18.0


  parent reply	other threads:[~2018-07-06 17:53 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
2018-07-06 17:50 ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
2018-07-10 15:20   ` Chen-Yu Tsai
2018-07-06 17:50 ` [PATCH 02/17] drm/sun4i: " Jernej Skrabec
2018-07-10 15:20   ` Chen-Yu Tsai
2018-07-06 17:50 ` [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
2018-07-10 15:21   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
2018-07-10 15:23   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
2018-07-10 15:23   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
2018-07-06 20:40   ` Rob Herring
2018-07-06 20:44     ` Jernej Škrabec
2018-07-09 14:16       ` Rob Herring
2018-07-10 15:26   ` Chen-Yu Tsai
2018-07-06 17:51 ` Jernej Skrabec [this message]
2018-07-10 15:31   ` [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
2018-07-10 15:35   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 09/17] drm/sun4i: mixer: Read id from DT Jernej Skrabec
2018-07-10 15:40   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux Jernej Skrabec
2018-07-10 15:56   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon Jernej Skrabec
2018-07-10 16:12   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
2018-07-10 16:14   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
2018-07-10 15:49   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
2018-07-10 15:53   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
2018-07-10 16:16   ` Chen-Yu Tsai
2018-07-06 17:51 ` [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
2018-07-10 16:09   ` Chen-Yu Tsai
2018-07-10 16:18     ` Jernej Škrabec
2018-07-10 19:41       ` [linux-sunxi] " Jernej Škrabec
2018-07-06 17:51 ` [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
2018-07-10 16:09   ` Chen-Yu Tsai

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=20180706175113.26698-8-jernej.skrabec@siol.net \
    --to=jernej.skrabec@siol.net \
    --cc=airlied@linux.ie \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mark.rutland@arm.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=robh+dt@kernel.org \
    --cc=wens@csie.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox