From patchwork Sat Feb 25 08:01:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9591519 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 1C442604A2 for ; Sat, 25 Feb 2017 08:02:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 076B828640 for ; Sat, 25 Feb 2017 08:02:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F008528685; Sat, 25 Feb 2017 08:02:24 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 9784228640 for ; Sat, 25 Feb 2017 08:02:24 +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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3N+6FXXK386YKfcnHupb++uUDAMJuFIWYvj+OQxb9Jk=; b=XVfOLJFc9M/FcMv5GA/eZslEe 7V5ewAmgncObI9tlze4ZyzOtSn5/vEd9q1mG4jn0wkvRtOeN1Lf/YKqfDoxbLkkOLApwEE0Tgg3wE TzYoGu/T+4Jlt+e5azQX7PutA2W7WU/plXI9nFKHvsnGHDbkVCxRlV4Rnuj0wD0fqSHx+GKEqbL/H 5Xd7Z7vHeWvrJQ1hiuhc8EGtoFcFfMULrFNmQj5td9ROUURnS1SrXY3CpiDUo3lEF6PeO5fKwnLt3 hW4iU76hHEvL99CswQgieBqsuXyn3z8d8fmKgJyNFvQVCAdothLvBx0wTPHUZ7mXcWYFQ99QFMv0y f4e8NUdgw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1chXJ0-0005PG-Ib; Sat, 25 Feb 2017 08:02:14 +0000 Received: from smtp03.smtpout.orange.fr ([80.12.242.125] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1chXIZ-0005LR-HP for linux-arm-kernel@lists.infradead.org; Sat, 25 Feb 2017 08:01:51 +0000 Received: from [127.0.0.1] ([92.140.162.61]) by mwinf5d05 with ME id ow1K1u00d1KnKiL03w1L9c; Sat, 25 Feb 2017 09:01:24 +0100 X-ME-Helo: [127.0.0.1] X-ME-Date: Sat, 25 Feb 2017 09:01:24 +0100 X-ME-IP: 92.140.162.61 Subject: Re: [PATCH] [media] exynos4-is: Add missing 'of_node_put' To: Javier Martinez Canillas , kyungmin.park@samsung.com, s.nawrocki@samsung.com, mchehab@kernel.org, kgene@kernel.org, krzk@kernel.org References: <20170123211656.11185-1-christophe.jaillet@wanadoo.fr> <2357ef6e-8d90-77d0-0399-21fec41389a1@osg.samsung.com> Newsgroups: gmane.linux.kernel.janitors, gmane.linux.drivers.video-input-infrastructure, gmane.linux.ports.arm.kernel, gmane.linux.kernel.samsung-soc, gmane.linux.kernel From: Christophe JAILLET Message-ID: Date: Sat, 25 Feb 2017 09:01:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <2357ef6e-8d90-77d0-0399-21fec41389a1@osg.samsung.com> X-Antivirus: avast! (VPS 170224-1, 24/02/2017), Outbound message X-Antivirus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170225_000148_034348_90A06FE4 X-CRM114-Status: GOOD ( 14.88 ) 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: linux-samsung-soc@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org 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 Le 24/02/2017 à 22:19, Javier Martinez Canillas a écrit : > Thanks for the patch, but Krzysztof sent the exact same patch before > [0]. There > was feedback from Sylwester at the time that you can also look at [0]. Could you > please take that into account and post a patch according to what he suggested? > > [0]: http://lists.infradead.org/pipermail/linux-arm-kernel/2016-March/415207.html > > Best regards, Hi, apparently, the patch has already been taken into -next by Mauro Carvalho Chehab. Moreover, I personally don't think that what is proposed in [0] is more readable. There is not that much code between 'of_get_next_child' and 'of_node_put' in the normal path and not so many error handling paths between the 2 function calls. Adding some indentation level is not an improvement, IMHO. If you really want, I could propose something like the code below (not carefully checked, just to give an idea), but honestly, I don't think it is needed. It avoids some new indent and avoids duplicating 'of_node_put'. Tell me if you think it is an improvement and I'll send a patch. CJ pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601; @@ -447,22 +444,28 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, pd->fimc_bus_type = FIMC_BUS_TYPE_ISP_WRITEBACK; else pd->fimc_bus_type = pd->sensor_bus_type; if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) { - of_node_put(rem); - return -EINVAL; + ret = -EINVAL; + goto put_rem; } fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_OF; fmd->sensor[index].asd.match.of.node = rem; fmd->async_subdevs[index] = &fmd->sensor[index].asd; fmd->num_sensors++; +out: + ret = 0; +put_rem: of_node_put(rem); - return 0; + +put_ep: + of_node_put(ep); + return ret; } /* Register all SoC external sub-devices */ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) { diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index e3a8709138fa..da5b76c1df98 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -385,38 +385,35 @@ static void fimc_md_pipelines_free(struct fimc_md *fmd) static int fimc_md_parse_port_node(struct fimc_md *fmd, struct device_node *port, unsigned int index) { struct fimc_source_info *pd = &fmd->sensor[index].pdata; - struct device_node *rem, *ep, *np; + struct device_node *rem = NULL, *ep = NULL, *np; struct v4l2_of_endpoint endpoint; int ret; /* Assume here a port node can have only one endpoint node. */ ep = of_get_next_child(port, NULL); if (!ep) return 0; ret = v4l2_of_parse_endpoint(ep, &endpoint); - if (ret) { - of_node_put(ep); - return ret; - } + if (ret) + goto put_ep; if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) { - of_node_put(ep); - return -EINVAL; + ret = -EINVAL; + goto put_ep; } pd->mux_id = (endpoint.base.port - 1) & 0x1; rem = of_graph_get_remote_port_parent(ep); - of_node_put(ep); if (rem == NULL) { v4l2_info(&fmd->v4l2_dev, "Remote device at %s not found\n", ep->full_name); - return 0; + goto out; } if (fimc_input_is_parallel(endpoint.base.port)) { if (endpoint.bus_type == V4L2_MBUS_PARALLEL)