From patchwork Fri Jul 6 17:51:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 10512299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0368B6024A for ; Fri, 6 Jul 2018 18:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0F4728791 for ; Fri, 6 Jul 2018 18:09:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E543F28796; Fri, 6 Jul 2018 18:09:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D6BE28791 for ; Fri, 6 Jul 2018 18:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=i4SLFydb464bT3frfMqe7w568LmV3ossr7kAxOLJUjM=; b=CHnP+BDa9TWtL0mD6pupUUj0GM E+TMw9KkoeNGyqBfuQEw53aFraS+92caEc83aiNs6yKZx+Si5ckaBxU2HNbOQ15tj8wUh2qTLzpI8 bS/Sk0xvOWLm86ihUVT23DCmxF+ACC9V/I+jRsZsQWCVK4PW9Vfo8BpTlMnLRYuVQo2XZlcwQXYNU u+DwzvPFi+tQu42cxFJQXbtst4Xt3pe3eHl/a9JHvVjy4SfyhLC41S3PVo+RKb2tesCgYYrjxFOH6 5Hw8HDFo4P39YWnSfX4kD/7F5awhOvVimh1qx66V51fON/onUJ1G4CEjXPF79gdfLsEajXrNW3XNK ZCwtgFKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbVAX-0001uv-3b; Fri, 06 Jul 2018 18:09:21 +0000 Received: from mailoutvs52.siol.net ([185.57.226.243] helo=mail.siol.net) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbUvH-00075H-Nd for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2018 17:53:40 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id A0AF7520BE8; Fri, 6 Jul 2018 19:53:23 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta11.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta11.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7rnDl-HF_xKI; Fri, 6 Jul 2018 19:53:23 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 2AD565211D8; Fri, 6 Jul 2018 19:53:23 +0200 (CEST) Received: from localhost.localdomain (unknown [194.152.15.144]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id A04875211DC; Fri, 6 Jul 2018 19:53:20 +0200 (CEST) From: Jernej Skrabec To: maxime.ripard@bootlin.com, wens@csie.org, robh+dt@kernel.org 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 Message-Id: <20180706175113.26698-8-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706175113.26698-1-jernej.skrabec@siol.net> References: <20180706175113.26698-1-jernej.skrabec@siol.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180706_105336_580722_7C8F2240 X-CRM114-Status: GOOD ( 10.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Chen-Yu Tsai --- 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; }