From patchwork Fri Mar 11 12:30:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 8565361 Return-Path: X-Original-To: patchwork-linux-arm@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 11512C0553 for ; Fri, 11 Mar 2016 12:33:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 364A620268 for ; Fri, 11 Mar 2016 12:33:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39B4B20253 for ; Fri, 11 Mar 2016 12:33:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeME4-0002t4-Ic; Fri, 11 Mar 2016 12:31:28 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeMDz-0002iK-2a for linux-arm-kernel@lists.infradead.org; Fri, 11 Mar 2016 12:31:24 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O3V00C7SK3MFK20@mailout3.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 11 Mar 2016 12:30:58 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-d2-56e2ba82164b Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 90.1C.21385.28AB2E65; Fri, 11 Mar 2016 12:30:58 +0000 (GMT) Received: from [106.116.147.32] by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O3V00FPRK3L7R40@eusync3.samsung.com>; Fri, 11 Mar 2016 12:30:58 +0000 (GMT) From: Sylwester Nawrocki Subject: Re: [RFT 1/2] [media] exynos4-is: Add missing endpoint of_node_put on error paths To: Krzysztof Kozlowski References: <1453768906-28979-1-git-send-email-k.kozlowski@samsung.com> Message-id: <56E2BA7D.9050500@samsung.com> Date: Fri, 11 Mar 2016 13:30:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <1453768906-28979-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNLMWRmVeSWpSXmKPExsVy+t/xq7pNux6FGdxYIm7x5u0aJovXLwwt +h+/ZrY42/SG3WLT42usFj0btrJazDi/j8li9bMKBw6PTas62Tw2L6n32NJ/l92jb8sqRo/P m+QCWKO4bFJSczLLUov07RK4Mpo3d7EXXJComHj0PnsD4y6hLkZODgkBE4l5R0+wQdhiEhfu rQeyuTiEBJYySrxcu44FJCEk8JxR4tcjCRCbTcBQovdoHyOILSwQI3H/0nawGhGg+MHd25kg 6t0ldjYvYQEZxCwwj0nizpVHrCAJXgEtidlnPwIlODhYBFQllh0rBwmLCkRIHO7sYocoEZT4 Mfke2ExOAQ+JHX1fwMqZBfQk7l/UAgkzC8hLbF7zlnkCo8AsJB2zEKpmIalawMi8ilE0tTS5 oDgpPddIrzgxt7g0L10vOT93EyMkyL/uYFx6zOoQowAHoxIP74drD8OEWBPLiitzDzFKcDAr ifBqbXkUJsSbklhZlVqUH19UmpNafIhRmoNFSZx35q73IUIC6YklqdmpqQWpRTBZJg5OqQZG rz5vi/53Z+fbXbdedJL3d9SeN4FLsxfsSU5Q8p3buORUiIT1l2q/3pLn2QYOS1qtKvOVL6hN Kzp0/KZTksRvu9LrkzxPuIQ0S7QlfK+sSjewyu+X9xXb3cT4817zO87aFKUHxWetK1k2r67O ajE5knPlY3r9vU3XG+5MiNVld03uU9pmdkSJpTgj0VCLuag4EQALtU2FbgIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160311_043123_388520_31152807 X-CRM114-Status: GOOD ( 21.17 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, Mauro Carvalho Chehab , Javier Martinez Canillas , Kyungmin Park , Kukjin Kim , 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On 01/26/2016 01:41 AM, Krzysztof Kozlowski wrote: > In fimc_md_parse_port_node() endpoint node is get with of_get_next_child() > but it is not put on error path. "is get" doesn't sound right to me, how about rephrasing this to: "In fimc_md_parse_port_node() reference count of the endpoint node "is incremented by of_get_next_child() but it is not decremented on error path." > Fixes: 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is") > Signed-off-by: Krzysztof Kozlowski > --- > Not tested on hardware, only built+static checkers. > --- > drivers/media/platform/exynos4-is/media-dev.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/exynos4-is/media-dev.c > b/drivers/media/platform/exynos4-is/media-dev.c > index f3b2dd30ec77..de0977479327 100644 > --- a/drivers/media/platform/exynos4-is/media-dev.c > +++ b/drivers/media/platform/exynos4-is/media-dev.c > @@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, > return 0; > > v4l2_of_parse_endpoint(ep, &endpoint); > - if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) > + if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) { > + of_node_put(ep); > return -EINVAL; > + } Thanks for the patch, it looks correct but it doesn't apply cleanly due to patches already in media master branch [1]. Could you refresh this patch and resend? Also I don't quite like multiple calls to of_node_put(), how about doing something like this instead: ---------------------------8<---------------------------------- ---------------------------8<---------------------------------- diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index feb521f..663d32e 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -397,18 +397,19 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, return 0; ret = v4l2_of_parse_endpoint(ep, &endpoint); - if (ret) { - of_node_put(ep); - return ret; + if (!ret) { + if (WARN_ON(endpoint.base.port == 0) || + index >= FIMC_MAX_SENSORS) { + ret = -EINVAL; + } else { + pd->mux_id = (endpoint.base.port - 1) & 0x1; + rem = of_graph_get_remote_port_parent(ep); + } } - - if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) - return -EINVAL; - - pd->mux_id = (endpoint.base.port - 1) & 0x1; - - rem = of_graph_get_remote_port_parent(ep); of_node_put(ep); + if (ret < 0) + return ret; + if (rem == NULL) { v4l2_info(&fmd->v4l2_dev, "Remote device at %s not found\n", ep->full_name);