From patchwork Mon Jan 25 15:21:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitoj Kaur Chawla X-Patchwork-Id: 8109501 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 82002BEEE5 for ; Mon, 25 Jan 2016 15:22:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9743520303 for ; Mon, 25 Jan 2016 15:22:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5460202E5 for ; Mon, 25 Jan 2016 15:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932496AbcAYPVp (ORCPT ); Mon, 25 Jan 2016 10:21:45 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:32964 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932674AbcAYPVm (ORCPT ); Mon, 25 Jan 2016 10:21:42 -0500 Received: by mail-pf0-f195.google.com with SMTP id e65so7063440pfe.0; Mon, 25 Jan 2016 07:21:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=YzXue3H1ko1AIWtar42oyUYWjp6MIrMPF/VJNjmPimg=; b=QP3lyH27eb2UJURRAo0pnZWSDhpUOAJopkl/dbJN5MTew1AaUGzZI6nn54lHQs2TYc Ka6YKyewIcYlzW7Arqm50wvgETAH/WD4fxxewUM3gFfcHm6xV4HsgO+itj6J/bKdkRHQ rgq9xPnREBcPf5gX93auhiwXUVanYxnHQVjuESfrZEBqCrhDbFfnO/I71uh0whw7bsXC u3Z+Q6rECb0/zT0MVNKiZp5mTY+VTwOBHDeJ0TSmhTjGqHrPrpaRyMAIVW1F9l8ShhUD qcm/QNowi0Infbosb4LloSp2XlIiP+woIISiZohqtFSGBroiFEc5+QtOBFKx++kPrFxW RpDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=YzXue3H1ko1AIWtar42oyUYWjp6MIrMPF/VJNjmPimg=; b=ZGEYhTtLjFeMQiXY440Ogby28jOB1qgcMAPIGG8aTmT/oV76ebcVeTK8zISSc1WuWh FIACnJYmvgk/MEyvDXHyC3Nt+0ma/hk+hkXr8aM6g0s1xuML7DkejSXBnsTANbFU+cHd ULcXRBtWuadrRjgLhLn9zP2xIy+ICEmQ6X8WxQSCfvB5CKoTvsQSQFV/ISuDyIxETjXi 5HctMY1nEzrjfk94KuK30j1ZRLujgOTANCtRsA/gUd1ydXDzH5npGRRgAxSLSXVLc6Pf TzrTPc5CdJHY/vF+Onz+ZcQnxrciHeSTEfgyoaxrKbW4rpJtgm3l4F9SG7q+5xQBGHDV 8DEg== X-Gm-Message-State: AG10YOSpfIV8Kb+POJaeleQGaRrbwAB6jT4oEjjMi/RfNdJe1dE7GuuhFYN76qXLrXlE9Q== X-Received: by 10.98.74.9 with SMTP id x9mr26726583pfa.14.1453735302139; Mon, 25 Jan 2016 07:21:42 -0800 (PST) Received: from localhost ([110.227.143.170]) by smtp.gmail.com with ESMTPSA id o67sm29391132pfa.58.2016.01.25.07.21.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 25 Jan 2016 07:21:41 -0800 (PST) Date: Mon, 25 Jan 2016 20:51:37 +0530 From: Amitoj Kaur Chawla To: kyungmin.park@samsung.com, s.nawrocki@samsung.com, mchehab@osg.samsung.com, kgene@kernel.org, k.kozlowski@samsung.com, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr Subject: [PATCH] media: platform: exynos4-is: media-dev: Add missing of_node_put Message-ID: <20160125152136.GA19484@amitoj-Inspiron-3542> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP for_each_available_child_of_node and for_each_child_of_node perform an of_node_get on each iteration, so to break out of the loop an of_node_put is required. Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows: // @@ local idexpression n; expression e,r; @@ for_each_available_child_of_node(r,n) { ... ( of_node_put(n); | e = n | + of_node_put(n); ? break; ) ... } ... when != n // Signed-off-by: Amitoj Kaur Chawla Reviewed-by: Krzysztof Kozlowski --- drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 4f5586a..09f6e54 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) continue; ret = fimc_md_parse_port_node(fmd, port, index); - if (ret < 0) + if (ret < 0) { + of_node_put(node); goto rpm_put; + } index++; } @@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) for_each_child_of_node(ports, node) { ret = fimc_md_parse_port_node(fmd, node, index); - if (ret < 0) + if (ret < 0) { + of_node_put(node); break; + } index++; } rpm_put: @@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd, ret = fimc_md_register_platform_entity(fmd, pdev, plat_entity); put_device(&pdev->dev); - if (ret < 0) + if (ret < 0) { + of_node_put(node); break; + } } return ret;