Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1242595imm; Wed, 23 May 2018 12:40:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp7P3HleZyo6xUOvVDyUidSp7E9Ap1gyg8SeQj8ze7n/I866Mvq1Fppe1CutWONacOjptK8 X-Received: by 2002:a63:798d:: with SMTP id u135-v6mr3247385pgc.401.1527104409513; Wed, 23 May 2018 12:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527104409; cv=none; d=google.com; s=arc-20160816; b=HKXwjDNmvwp1+BSOmX8vMF/DctheQpmJVmX1rfeG0e5YtiMqOUEROlS8i8lrBRkE45 JnAX976u0bnujkUVde2e5QyHZKKeodlPRyHTlj4Ouz2iZibqDEX/wUrDil+ptSqJOCju DEyabG3ReoLTXg+erStCGGzEzoMvK+UgCsXIvr2EvJxzNj+dXTrCGrpphwBweQWfkeQh cvcbwgiuTUAyFfbo+nEEZZckepzfLN9vsCEBgdJfcz/AaZg3g1rR6Y7cuDFH4lgockiE E6SDVrx2mziBAFjyqwDwta7Zq81XBmf0ezpBbJ3CmDZ3A5oKZ4n0Hf3r3KmfzrEc5/Wa 1R/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Nc1N1q1oqTVsLBzvWkNAi53dd3cg8pGE0Kz39ZRerCI=; b=cM0/Kblby8yf452WpcOYmmvlEkq6i7aEEisx6AGomVvtTXL7DQ5Q8uwy7HRAC6VHSM dYccovWtAocuRHsqiIz8FSGWOrc5wJEmrjrvJ3xfCKxSxwMYrs2dcpxbHiXZqk6MG2et 490JGXnSSqSa7Cn0kVubwz0/hPb32c1VkUxnPhq8/uQiNql5PLVKRCm39dRhCZ0jcwZy QyE6OB8vA16SFXYIY7BXrujjezN9Vz3uUboNPshuMpZS+h1YPyKspAxPeENX6/PpsHVM WgpUpZ+JvTGrZCron0/ux46j0GiwmGqw66IkywpADwf334BWm3arLmxJbHip11bCwSn5 SjBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i67-v6si19491207pfi.95.2018.05.23.12.39.55; Wed, 23 May 2018 12:40:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934368AbeEWTjG (ORCPT + 99 others); Wed, 23 May 2018 15:39:06 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:13785 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934311AbeEWTjD (ORCPT ); Wed, 23 May 2018 15:39:03 -0400 X-IronPort-AV: E=Sophos;i="5.49,434,1520895600"; d="scan'208";a="328129393" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 23 May 2018 21:38:58 +0200 From: Julia Lawall To: Benjamin Herrenschmidt Cc: kernel-janitors@vger.kernel.org, Paul Mackerras , Michael Ellerman , Bjorn Helgaas , linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] pci/hotplug/pnv-php: add missing of_node_put Date: Wed, 23 May 2018 21:07:15 +0200 Message-Id: <1527102436-13447-5-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527102436-13447-1-git-send-email-Julia.Lawall@lip6.fr> References: <1527102436-13447-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The device node iterators perform an of_node_get on each iteration, so a jump out of the loop requires an of_node_put. The semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // @@ expression root,e; local idexpression child; iterator name for_each_child_of_node; @@ for_each_child_of_node(root, child) { ... when != of_node_put(child) when != e = child + of_node_put(child); ? break; ... } ... when != child // Signed-off-by: Julia Lawall --- drivers/pci/hotplug/pnv_php.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c index d441006..6c2e8d7 100644 --- a/drivers/pci/hotplug/pnv_php.c +++ b/drivers/pci/hotplug/pnv_php.c @@ -220,12 +220,16 @@ static int pnv_php_populate_changeset(struct of_changeset *ocs, for_each_child_of_node(dn, child) { ret = of_changeset_attach_node(ocs, child); - if (ret) + if (ret) { + of_node_put(child); break; + } ret = pnv_php_populate_changeset(ocs, child); - if (ret) + if (ret) { + of_node_put(child); break; + } } return ret;