Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3047323imu; Wed, 7 Nov 2018 04:15:04 -0800 (PST) X-Google-Smtp-Source: AJdET5dlmkSW7QQq4+WR5GY8MdpR6moZvP27o+2ej/svMMjVeLxPpm60kALDYQhm7ns9N+h11v5a X-Received: by 2002:a62:3046:: with SMTP id w67-v6mr1549245pfw.177.1541592903980; Wed, 07 Nov 2018 04:15:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541592903; cv=none; d=google.com; s=arc-20160816; b=TX4UeRe+xlqXy5gkPipfs5IbvinR/bEXsA3OGd06jkTem3YGXzVHRcMMX0c8MEe1zW DRj194afC0kJTlTPJ9Kr5ewgELugtd8AEJrYthyXOlWS7G+2gLe8bqT69851HQDSQx93 fzqu/AO4H4LJY3YjHM5678jhh4tEImVxPJq4EaI4zG2Y7PUI5PWrl0/sHykmvh8r1boQ eU7qPnYGGldBzuP/iXTBQtYicUtTmgLSdd1QC0dGdPxAHs5u0QpO7cv16NasBowkyhUb DBmsrYjvUhPXPbtUf5y2v+JREQUx7lHMk8/CvcWncjLLmSGMg0E8TJUsaDaGbwFdqcAk 7nEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=fuJ+AHibwOf/lvTMnU6reZzy+L3DmiXvPv0cl/30DQY=; b=A2rWsMenGF10D5ADAap0ugKAVTG+6Z5+tnviIJ2Q7JGcfalBofGxK6XqF6LJKfAyjh kTT8Ms0/YJ039isvvivbSxtf9rrCOJnIWpxBLbxz9zCbsqExK7zHTvVnRiYOPO9KmUn1 VXEvNZE4WTkNQeV+a0i+/LFb8s8zIKKHIVCzQburowdcrMskoSvFDtsBf6AxW3Ee92E9 ZvQHnGvmkoF2GAObTuloIDspYnBVS1bMnE75IH4i/YpuZmpPrWrPEznfFy77kz7wMN/Q skC5BuWHaiuz+LTT8klq8lc8DIt0Si2aIZIuoxldIrptS9gDe2h0rAvVtz9r1jxWTrvq nJGA== 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 88-v6si496326plb.57.2018.11.07.04.14.47; Wed, 07 Nov 2018 04:15:03 -0800 (PST) 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 S1727029AbeKGVod (ORCPT + 99 others); Wed, 7 Nov 2018 16:44:33 -0500 Received: from ozlabs.org ([203.11.71.1]:54865 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeKGVod (ORCPT ); Wed, 7 Nov 2018 16:44:33 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42qlhc3dp4z9sCX; Wed, 7 Nov 2018 23:14:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: frowand.list@gmail.com, Rob Herring , Pantelis Antoniou , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-fpga@vger.kernel.org Subject: Re: [PATCH v6 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs In-Reply-To: <1541431515-25197-4-git-send-email-frowand.list@gmail.com> References: <1541431515-25197-1-git-send-email-frowand.list@gmail.com> <1541431515-25197-4-git-send-email-frowand.list@gmail.com> Date: Wed, 07 Nov 2018 23:14:23 +1100 Message-ID: <87pnvhqe3k.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org frowand.list@gmail.com writes: > From: Frank Rowand > > There is a matching of_node_put() in __of_detach_node_sysfs() > > Remove misleading comment from function header comment for > of_detach_node(). > > This patch may result in memory leaks from code that directly calls > the dynamic node add and delete functions directly instead of > using changesets. > > Tested-by: Alan Tull > Signed-off-by: Frank Rowand This seems sensible to me. I guess we could argue about whether the sysfs code needs its own reference, but it certainly doesn't hurt that it does, as long as it's handled symmetrically - which it is now. Acked-by: Michael Ellerman (powerpc) > --- > > This patch should result in powerpc systems that dynamically > allocate a node, then later deallocate the node to have a > memory leak when the node is deallocated. > > The next patch in the series will fix the leak. I think this should go in the changelog, it's useful information that we don't want to lose track of once this is applied. Either that or we actually squash the two patches together when applying to avoid the bisection break. cheers > drivers/of/dynamic.c | 3 --- > drivers/of/kobj.c | 4 +++- > 2 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c > index 12c3f9a15e94..146681540487 100644 > --- a/drivers/of/dynamic.c > +++ b/drivers/of/dynamic.c > @@ -272,9 +272,6 @@ void __of_detach_node(struct device_node *np) > > /** > * of_detach_node() - "Unplug" a node from the device tree. > - * > - * The caller must hold a reference to the node. The memory associated with > - * the node is not freed until its refcount goes to zero. > */ > int of_detach_node(struct device_node *np) > { > diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c > index 7a0a18980b98..c72eef988041 100644 > --- a/drivers/of/kobj.c > +++ b/drivers/of/kobj.c > @@ -133,6 +133,9 @@ int __of_attach_node_sysfs(struct device_node *np) > } > if (!name) > return -ENOMEM; > + > + of_node_get(np); > + > rc = kobject_add(&np->kobj, parent, "%s", name); > kfree(name); > if (rc) > @@ -159,6 +162,5 @@ void __of_detach_node_sysfs(struct device_node *np) > kobject_del(&np->kobj); > } > > - /* finally remove the kobj_init ref */ > of_node_put(np); > } > -- > Frank Rowand