From patchwork Thu Oct 12 16:04:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10002245 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 0BC0660325 for ; Thu, 12 Oct 2017 16:05:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F213228DB5 for ; Thu, 12 Oct 2017 16:04:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E635428DFA; Thu, 12 Oct 2017 16:04:59 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 672FB28DE0 for ; Thu, 12 Oct 2017 16:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751682AbdJLQE6 (ORCPT ); Thu, 12 Oct 2017 12:04:58 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:48036 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbdJLQE5 (ORCPT ); Thu, 12 Oct 2017 12:04:57 -0400 Received: by mail-pf0-f194.google.com with SMTP id z11so5479703pfk.4 for ; Thu, 12 Oct 2017 09:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RFCZp3HsqLGhBXQqKyshHM0uT063L95YBP1c7D8t/Kk=; b=gvKd/lGdc2J8z2M/8jjCB7MBXV+t0sQUkGrskCVXLbZuseaIhQMF5wiiIAB/vruj1x CrWsCZbWXZbpwc+x5lbkI5ojyVnEc3ABqyFphfqWZI7AcaLNOppwrnrIlx8d1bfVJttQ ovkGtvQEqgmyGEzMOiJMyMMpp4MNdfwyWMvCfN4qDdxpugdmNSEDE/0pQX32mQSJwpYz jc2hP/f0M7ECLP20KrbNUzYz/xOja8dyr5ccqp0EtJ5jKftUtPcvdmaVSrnQ+DhbhDUk Sm4FUAqckE+fAxW83j2BgxyTJtJMfnfW6XbPScdRgN8rooUOV89743V4O2k8vPpaCGDh tucg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RFCZp3HsqLGhBXQqKyshHM0uT063L95YBP1c7D8t/Kk=; b=PsEpVBV+xkrymjTH89jOupDJp2q+1OJAcIIgkzpwerz2pojCFTAtdvKhV+mIKs8qtN 2vv+O8OvYXJq63AqJOiLw3DqqErqLV9BIhxqC1NbVdaNUWDqb/fbVavf14o+1kCv2uoG Z1pwzNPJfcL3PdDo2N1OO+OGtlSEWtvgHn+OvIzp0GeNv2KVNk2UOVLG7Hfc+61ORPTJ hgM7JjEw1J2RbkzL7oIR27MrKI4Z3GOVRCb5fTOAbSU1k+GXbF02ckmSZGyvjmXZ1Mf4 c15Wkn6W0TQixXcQJlDyd/7/Mi2f2b2lS2QEm96CvLZXAtZ1JfQ1JR1I3Bw+tf2H454E CnRQ== X-Gm-Message-State: AMCzsaW8RVO+A6YQrTFu4kK7xjDgkudD78irRbMOji4raSLKLJezKOI3 ZDPCfSjMir9TsRppFJOizWlw1w== X-Google-Smtp-Source: AOwi7QBU7WxjxX02N1cyhoqtEt3lVnhCObD5G398h/kNw0Vj8LWoBgPrgf+u5oSukQa2huywYNOSLA== X-Received: by 10.84.240.196 with SMTP id l4mr596963plt.261.1507824297226; Thu, 12 Oct 2017 09:04:57 -0700 (PDT) Received: from mita-ThinkPad-T540p.lan ([240f:4:c2bc:1:ec18:f5a1:1d8f:bb9f]) by smtp.gmail.com with ESMTPSA id p70sm31691307pfk.130.2017.10.12.09.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 09:04:56 -0700 (PDT) From: Akinobu Mita To: linux-media@vger.kernel.org, Mauro Carvalho Chehab Cc: Akinobu Mita , Hyun Kwon , Laurent Pinchart Subject: [PATCH] media: xilinx-video: fix bad of_node_put() on endpoint error Date: Fri, 13 Oct 2017 01:04:44 +0900 Message-Id: <1507824284-17809-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When iterating through all endpoints using of_graph_get_next_endpoint(), the refcount of the returned endpoint node is incremented and the refcount of the node which is passed as previous endpoint is decremented. So the caller doesn't need to call of_node_put() for each iterated node except for error exit paths. Otherwise we get "OF: ERROR: Bad of_node_put() on ..." messages. Cc: Hyun Kwon Cc: Laurent Pinchart Signed-off-by: Akinobu Mita Reviewed-by: Laurent Pinchart --- drivers/media/platform/xilinx/xilinx-vipp.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index ebfdf33..e5c80c9 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -76,20 +76,16 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, struct xvip_graph_entity *ent; struct v4l2_fwnode_link link; struct device_node *ep = NULL; - struct device_node *next; int ret = 0; dev_dbg(xdev->dev, "creating links for entity %s\n", local->name); while (1) { /* Get the next endpoint and parse its link. */ - next = of_graph_get_next_endpoint(entity->node, ep); - if (next == NULL) + ep = of_graph_get_next_endpoint(entity->node, ep); + if (ep == NULL) break; - of_node_put(ep); - ep = next; - dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep); ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); @@ -200,7 +196,6 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) struct xvip_graph_entity *ent; struct v4l2_fwnode_link link; struct device_node *ep = NULL; - struct device_node *next; struct xvip_dma *dma; int ret = 0; @@ -208,13 +203,10 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) while (1) { /* Get the next endpoint and parse its link. */ - next = of_graph_get_next_endpoint(node, ep); - if (next == NULL) + ep = of_graph_get_next_endpoint(node, ep); + if (ep == NULL) break; - of_node_put(ep); - ep = next; - dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep); ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link);