Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4642091imm; Mon, 15 Oct 2018 19:43:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV63ZBB6x+EP7Pu/5wb9Su8s/7219+htFhKPwf/+C9Cq/FJCeq+T93BXELBLEPH4CFitk4E81 X-Received: by 2002:a65:4103:: with SMTP id w3-v6mr18768722pgp.284.1539657790869; Mon, 15 Oct 2018 19:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539657790; cv=none; d=google.com; s=arc-20160816; b=MTv/mJVUCK7fBGtwNlhvFG3CRFkUBhnelFpFct2DARq++m5IrDhv+j7pVruhBljZFf f5c7K/76hFHF5zIRYWqTwiyq1RehTnIOAd1gUmCJuwKd6HoSHIdL/BM+sMICrQbv1wal BRWCdiBIjfFErg+VeI33ap9Wt8pmjnqebhmuuYoISITJ2ObIHO7FRmmj0kP3r101U3vm +bqAXDstGVwsfpB5RcvEV1e1L9Kg+AoSUlVCVt+FDUhEkzpB+SvA41/r5qcYdmnYpiFh cr7Ifwonf/XQYg9B4lipyoiX6XGuNyMNLzpg1yUTsPa8luY3mGTh6XP4IdvywiMCRJV5 xWcQ== 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:dkim-signature; bh=NBR84y3mbc7GWOaSoRjimr7kNqkK04efsf5Z6wzYUy8=; b=vGxbWTIbLpeUZyKflU4NXKETxL78+JP8ARKGPEYGiEtX38DcsuC1P2VTeiIOVkwtaY 8C/yfvgSQJx4c2WkcyGcD81U7Qdbx62+Aws2uik6bx+icnRLN9bsqewhhg1yBv5Xroig pmwr1csdeHm3krgz58Gkb3eBy/Wol4N2J8tMVjTJBWGSDG4zHn/yX1R8ATwrQ8F91sTk ly32jC+SjAKYgfGQ6+pNUjb4FoGdVhfbhvRozVcXSJLSz8vvDkLPRVI3mLh1ZmnECneJ KfoodsrMzcCX2WazOnWzG/2m6bPACWPZhmLB3Hjkbi67zqV9T3Vkf6XXcaPHweKiK4yN AbNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=msottjjT; 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 j16-v6si11819727pgg.350.2018.10.15.19.42.55; Mon, 15 Oct 2018 19:43:10 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=msottjjT; 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 S1727067AbeJPK1T (ORCPT + 99 others); Tue, 16 Oct 2018 06:27:19 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38113 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbeJPK1T (ORCPT ); Tue, 16 Oct 2018 06:27:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id f29-v6so10657629pff.5; Mon, 15 Oct 2018 19:39:15 -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:in-reply-to:references; bh=NBR84y3mbc7GWOaSoRjimr7kNqkK04efsf5Z6wzYUy8=; b=msottjjT7t57byr3yNiOwhXhMihvPQXQigcvhD5f5pbFKd/ThIFvO8wHGibRyVHpRL Ub5ey294l0Pr4x3AV2gBbzJcMxky3UEdVbfQ2dcPwEMUS+fSuIiqyYEcSJtLdNxz+h4l H+mkwxYhtvAVvzrrc7fgzJj8ONhLwA+gbBEltr1BdtFbY1m51zbnw1sXTLEqNWjvTQTI fKgiGnrp01wg+cYHx3LuVuLrYy3R6jtGS4fonenuSzvXd3H5Ts5LIrv9TH5eELD0Lwlp NUvLm/OpUGQis62W0stkC3RS26QwXJf5caSTUCqX1bWBVph/VhekQTMy8t3V7nA+EEg8 ypwQ== 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:in-reply-to :references; bh=NBR84y3mbc7GWOaSoRjimr7kNqkK04efsf5Z6wzYUy8=; b=jp+NNpcAVrKMlxfU+tzGr9mDhxhim4N7bFlzaC7ceF+auzN/377sg45YJ7a1fgQ3uJ l+u644h2I7+BpXy+wuNpJHy36w+J49+9ZdWxpodkNq7D3cAoVLtUH1yDg4c1MkPGPZq9 C1DkkCx9fmkumQJaNMUGw8pW98+ARNEfRAAKBJYhlYPSuMB6nmTX5sWDTXJ8PJMp1fLw W5+G1ddS0X60eYw/BWS3EeYcJ9OyHhs8ITTc00uMB87KakOaeAPHIJTvLMY3cDVgHztd 8CSn251J29BJt7Azhazi6Cxv9mkRCKDnph3TpeZuymxQoDb8e+3mjfQWVrNi23zr1gvj KX7g== X-Gm-Message-State: ABuFfoj7jTIgHEIhSWrfgUXPDV6BeHRxTvd0z1DX8SXS7Yd+PJKOG5Y4 AjKo9TfnOlMPysKllRZ8xx0= X-Received: by 2002:a63:d64b:: with SMTP id d11-v6mr18251971pgj.450.1539657555084; Mon, 15 Oct 2018 19:39:15 -0700 (PDT) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id u79-v6sm18620287pfd.117.2018.10.15.19.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 19:39:14 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , 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: [PATCH v4 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs Date: Mon, 15 Oct 2018 19:37:23 -0700 Message-Id: <1539657458-24401-4-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539657458-24401-1-git-send-email-frowand.list@gmail.com> References: <1539657458-24401-1-git-send-email-frowand.list@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Frank Rowand --- 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. 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 24c97b7a050f..fe8816cca99b 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