From patchwork Mon Nov 5 15:25:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 10668475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 392BC175A for ; Mon, 5 Nov 2018 15:27:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 281B0285A9 for ; Mon, 5 Nov 2018 15:27:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BAE028660; Mon, 5 Nov 2018 15:27:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 B957A285A9 for ; Mon, 5 Nov 2018 15:26:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730232AbeKFArK (ORCPT ); Mon, 5 Nov 2018 19:47:10 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35908 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729760AbeKFArJ (ORCPT ); Mon, 5 Nov 2018 19:47:09 -0500 Received: by mail-pg1-f194.google.com with SMTP id z17-v6so4384747pgv.3; Mon, 05 Nov 2018 07:26:56 -0800 (PST) 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=Eps1KFA7lEghL7/4dmQbZz3ImKypsw61x2xaOWgNqDg=; b=gTlZt5u6/vzKqoG3PjCr8lAQ26z5MBBKNrCnWqffkqsJlD5p6kXawKm6ffNfxxIQT/ RzUgUTxlCAv1sCjEsZNkIFACMb7xfs8Lf08QdG9wJHa9LQgYJuu3MhcIUwkA5OltE/nn KWUp8nAdz8iaay9kFo10eXDaWTkjTFtB9ikhiraNL16qwmBh2ntT1/XRkyuKfP1lGGiQ FI7II6KnWwG3hbiErSQXPqBbldUtlsEk5MczQ+hae+aNNE1xoWN+Py81rHXDX2ncKwQm OLV8oNcGGdu5RmZKELszJbV6l5rOvAQ/qkcOUVX+/hxVZ2grPzjtWPRd0gsu5USArgFB kANw== 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=Eps1KFA7lEghL7/4dmQbZz3ImKypsw61x2xaOWgNqDg=; b=kwmTIDK6t9f0FWAzCt0qNF+K/CLNVx+0yT5l7hBbIlLUAY6UGLpXETlZnWspdcw9qa 5Q7BGVV8GsYy0g/itW2VTIzGXZtYaJe+OcHE0mSSqUEOBTYQjGQijAv6jmE2oQxeP2r9 UvcNBG8EEYfpfPOHSgr9c92J1pUXV+6fU6F7BgT0Iw33UGMysFID1pupR9FfL2g1VraV cpmy+YfMimWbasrxeikcbK9n0OHqNznuNGF/psvz4YMtyzcLCVlTjFv3pcB6ZDSFpWcx 4jIVaSJWOG96KdtWvw53582c0eLUDmAPqBjI1yzYhRv0CM9CGPHK2OGW1xoCcJ9AedF0 YLiw== X-Gm-Message-State: AGRZ1gJKOGhuQ3YpZ2H7UXhc3RZvvT9hIZPTuM+Lj9SRLjYCrH90vEc5 qOYg+XZfNpF1pHC7WtyvFXj+0yQh X-Google-Smtp-Source: AJdET5el0E2+PBwqJW9dh4BMEuo83mkeQc3jYFOppW0RBR0EZIN6ZXgfPkxK0Uag69Vo4Ew5+zGS5A== X-Received: by 2002:a63:3c44:: with SMTP id i4mr20326569pgn.286.1541431616477; Mon, 05 Nov 2018 07:26:56 -0800 (PST) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id u76-v6sm37260578pfa.176.2018.11.05.07.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Nov 2018 07:26:55 -0800 (PST) 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 v6 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs Date: Mon, 5 Nov 2018 07:25:00 -0800 Message-Id: <1541431515-25197-4-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541431515-25197-1-git-send-email-frowand.list@gmail.com> References: <1541431515-25197-1-git-send-email-frowand.list@gmail.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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. 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); }