From patchwork Tue Jun 12 17:22:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 50233 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fSn18-0004Tw-Pl; Tue, 12 Jun 2018 17:23:39 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933429AbeFLRXg (ORCPT + 1 other); Tue, 12 Jun 2018 13:23:36 -0400 Received: from www.osadl.org ([62.245.132.105]:58253 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754209AbeFLRXf (ORCPT ); Tue, 12 Jun 2018 13:23:35 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id w5CHMdrw021809; Tue, 12 Jun 2018 19:22:46 +0200 From: Nicholas Mc Guire To: Mauro Carvalho Chehab Cc: Maxime Coquelin , Alexandre Torgue , Hans Verkuil , Hugues Fruchet , Philipp Zabel , Niklas Soderlund , Benjamin Gaignard , "Gustavo A. R. Silva" , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path Date: Tue, 12 Jun 2018 19:22:18 +0200 Message-Id: <1528824138-19089-2-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1528824138-19089-1-git-send-email-hofrat@osadl.org> References: <1528824138-19089-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=0.4 required=6.0 tests=BAYES_00, DATE_IN_FUTURE_96_Q autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The endpoint allocated by of_graph_get_next_endpoint() needs an of_node_put() in both error and success path. As ep is not used the refcount decrement can be right after the last use of ep. Signed-off-by: Nicholas Mc Guire Fixes: commit 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver") Acked-by: Hugues Fruchet --- Problem located with an experimental coccinelle script Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y CONFIG_VIDEO_STM32_DCMI=y (There are a number of sparse warnings - not related to the changes though) Patch is on top of "[PATCH 1/2] media: stm32-dcmi: drop unneceeary while(1) loop" against 4.17.0 (localversion-next is next-20180608) drivers/media/platform/stm32/stm32-dcmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 70b81d2..542d148 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -1610,10 +1610,9 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node) return -EINVAL; remote = of_graph_get_remote_port_parent(ep); - if (!remote) { - of_node_put(ep); + of_node_put(ep); + if (!remote) return -EINVAL; - } /* Remote node to connect */ dcmi->entity.node = remote;