From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BD20C282C4 for ; Wed, 13 Feb 2019 02:36:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8D9F206B6 for ; Wed, 13 Feb 2019 02:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550025365; bh=c1coEOAFrIk4JZ6hNnEYFW5q4936kHP3T89BWMirhAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=J3unYPIY5J2nHLkQVQiqY9ZKvfFEPLP1f5Y6OlUQUcqCRS6j4YaRcScux33+Z0bCc CUoVdJCKwVrfKVXBUDCKRmKfp8kScwmcqfYKrz+FK26Nh7lahhfiBAtfEkUcn4Z7LF 4uSrKdf5DTxt78HnJ6aH/WgKAGhyhIAFPh6tdOpQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732013AbfBMCft (ORCPT ); Tue, 12 Feb 2019 21:35:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:39338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388044AbfBMCfi (ORCPT ); Tue, 12 Feb 2019 21:35:38 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BBA0222C9; Wed, 13 Feb 2019 02:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550025337; bh=c1coEOAFrIk4JZ6hNnEYFW5q4936kHP3T89BWMirhAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oi0A3a/ZK6YjNtfAlOzUhSdn1H+9LISJwZ92LkMc5NJDQroDK71/mJrPpA1Vkay4k 6EAfP8IAL7WtrKybMAell1T9ESliZEmGC5445VvCYAdAt08R73MQ+4ja/MlazbVrnI j9dKJpZ/judq87vAsdwwWf7No9+fpzbwGqTJOAus= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Julia Lawall , Maxime Ripard , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.20 077/105] drm/sun4i: backend: add missing of_node_puts Date: Tue, 12 Feb 2019 21:33:08 -0500 Message-Id: <20190213023336.19019-77-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190213023336.19019-1-sashal@kernel.org> References: <20190213023336.19019-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julia Lawall [ Upstream commit 4bb0e6d7258213d4893c2c876712fbba40e712fe ] The device node iterators perform an of_node_get on each iteration, so a jump out of the loop requires an of_node_put. Remote and port also have augmented reference counts, so drop them on each iteration and at the end of the function, respectively. Remote is only used for the address it contains, not for the contents of that address, so the reference count can be dropped immediately. The semantic patch that fixes the first part of this problem is as follows (http://coccinelle.lip6.fr): // @@ expression root,e; local idexpression child; iterator name for_each_child_of_node; @@ for_each_available_child_of_node(root, child) { ... when != of_node_put(child) when != e = child + of_node_put(child); ? break; ... } ... when != child // Signed-off-by: Julia Lawall Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/1547369264-24831-5-git-send-email-Julia.Lawall@lip6.fr Signed-off-by: Sasha Levin --- drivers/gpu/drm/sun4i/sun4i_backend.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index bf49c55b0f2c..9f27d5464804 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -704,17 +704,18 @@ static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv, remote = of_graph_get_remote_port_parent(ep); if (!remote) continue; + of_node_put(remote); /* does this node match any registered engines? */ list_for_each_entry(frontend, &drv->frontend_list, list) { if (remote == frontend->node) { - of_node_put(remote); of_node_put(port); + of_node_put(ep); return frontend; } } } - + of_node_put(port); return ERR_PTR(-EINVAL); } -- 2.19.1