Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3216624imu; Wed, 7 Nov 2018 06:58:26 -0800 (PST) X-Google-Smtp-Source: AJdET5dhg6DvXWWGPRl9b9exUOlGb2JwUsA4x3wjGo1EsIA78BcDe+4X2wgnx6y1zUgPasbABWpO X-Received: by 2002:a17:902:7485:: with SMTP id h5-v6mr531927pll.172.1541602706161; Wed, 07 Nov 2018 06:58:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541602706; cv=none; d=google.com; s=arc-20160816; b=QqIspr8BVOcUGqgHd2zNAX8Xy7KYvw6Jb46H3F4Acwuj2T99ILunEo2uhkYe8ZHPGq a819hsKG3R0rDOn9ObseHJ8qfP86WANR8YWuCygvVHrfC3SQD7385iqeTES0PPEsU7us ++Vh9eOnHu4FBerqixBRVyAzPXeydB9OL3X8ynOXj13d5ZQA0xnwe3N975RIybd4oDn5 vo7TRKdpXm/HoQGfQyjWoCB49r5qL8TDVGw/KJLD3pH1wCFYHJs/z2Mhp9+cdYc0cU+X T4H3yPUdVKbwfJAc4KIegCTCNA1tbpCmZOmtWG52U/DxwdhQmM3SdtLJK4JMNvFYoN6H B75Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=yWpREYK2l3wwDZUw0wnv/+jhqdCA4YFRpIk44FmVWeY=; b=Pw+RvEtuO5vDlpdzdqT/Z6W9p/l2ZvdjFAJ1GDhICYLrfuLRTbY/B/llS07KUcX5nD WRPokPy+FviisBDZTQGP9fhYj3eByNd24DYT7ERbDWtPVKB1mC7u+C5H5WyC1FpW+J9E IK1yb9TDe+PZgtd/TZ65ITTnrpxN4bOQlUm0HLlE1ebElvYoI3XQcpLa5+a3nb/hofeK 4S36gq1EAWD1V92+EFO0pyzquXV31ntCUX8HUo+ZmLdSpZJ00vM58yrWDG2W4e2c+pqo D4TDuHncDr98pTba2+p2uxeNkft8xGtveEQhoGIQvLTmU5dkJU2WbnH6t6ogvCWICSRl pgsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DvRpiVs2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si859324pli.135.2018.11.07.06.58.10; Wed, 07 Nov 2018 06:58:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DvRpiVs2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728040AbeKHA22 (ORCPT + 99 others); Wed, 7 Nov 2018 19:28:28 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35613 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727604AbeKHA22 (ORCPT ); Wed, 7 Nov 2018 19:28:28 -0500 Received: by mail-pf1-f196.google.com with SMTP id v9-v6so5500737pff.2; Wed, 07 Nov 2018 06:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=yWpREYK2l3wwDZUw0wnv/+jhqdCA4YFRpIk44FmVWeY=; b=DvRpiVs2qLmj8ED0FattvUBafkC/6cPlaKucnxySA3z6BZG/TU/vV9BufmcRs04g7E y3aMNEvLBqCZzkyOttzBStnkRetz7Ac5SjQoU86Jom1A4onIrc1T4n1U73lSRdGsab/u zKv5IPNrz0PUefUvLvDAAaSgHuHgY8wfxbZQZzKiuYwybBVPRsFROc8r/hG1z4QNMkF7 kRoaYvve6XNRm/edQBGlmwNkT1om2rKBmom0eXghg2xjPihRK42We+3NgUxWrjvaLTH7 VN2jZV6jdxyoPQwjbOH9TJ6EdQBWZ9y3pIC+Q4oh31oIhKjogMfFkOnL7u3mJT0gggWm EDKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yWpREYK2l3wwDZUw0wnv/+jhqdCA4YFRpIk44FmVWeY=; b=ekya5bTTiFCcFbhef2fBELAKOrropzp8NO2ZNCle6qlB4sys+FuBWi9756QIaOkHXL oovY9uzZFTxxwbhrT6CRzE1SlLHTXsY4EUhB1Vy1KDWUTZKTd+Pa0weHHKffan0+P6+O 3YNnM2sHhyqMMVHq5a7uF5ck9h074t6TWJB1rZbH4q50FmWZiI0KFuMO6wEdLky1vxYF b94K0iBwc7MQ6N0C3cW1oCvYtyfTWJjA9UZQQNeUbNLyza7IewWGMgCMkPefjKrBwgqq g1btsTguv7wodJad7SyF25X3T9yrEJ/DsmItYLohXPQv1uTZD5rS6fT6ZxKqHo23xeYI 3Wig== X-Gm-Message-State: AGRZ1gJGGHN6BAhMS540bpl+x26ZFckQQMCGJVO9ueTEg9NkLtmHK5Hj nWhozJmYXN1c1fBXoJUdMlw= X-Received: by 2002:a62:1b4f:: with SMTP id b76-v6mr552210pfb.96.1541602666079; Wed, 07 Nov 2018 06:57:46 -0800 (PST) Received: from [192.168.1.70] (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id u5-v6sm800456pgk.46.2018.11.07.06.57.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 06:57:45 -0800 (PST) Subject: Re: [PATCH v6 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs To: Michael Ellerman , 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 References: <1541431515-25197-1-git-send-email-frowand.list@gmail.com> <1541431515-25197-4-git-send-email-frowand.list@gmail.com> <87pnvhqe3k.fsf@concordia.ellerman.id.au> From: Frank Rowand Message-ID: <2b742254-3b54-d862-5126-95ae7d5056f9@gmail.com> Date: Wed, 7 Nov 2018 06:57:43 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87pnvhqe3k.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/18 4:14 AM, Michael Ellerman wrote: > 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. Will do. -Frank > > 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 >