From patchwork Fri Nov 9 06:05:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 10675343 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 C534914D6 for ; Fri, 9 Nov 2018 06:09:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F1E2E0E5 for ; Fri, 9 Nov 2018 06:09:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A859B2E22C; Fri, 9 Nov 2018 06:09:16 +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 51DA22E0E5 for ; Fri, 9 Nov 2018 06:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbeKIPqt (ORCPT ); Fri, 9 Nov 2018 10:46:49 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41680 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbeKIPqs (ORCPT ); Fri, 9 Nov 2018 10:46:48 -0500 Received: by mail-pl1-f193.google.com with SMTP id p16-v6so445502plr.8; Thu, 08 Nov 2018 22:07:48 -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=PG2ocAMiVixrDeygGSkU3xeZwD7YrFAmHiDnBCDK3aM=; b=VULamfwBqYrbnPluR35Rr2eBZFcuavn4wc+03Gfgu0SfzcdrZ5PgTzaQ3ihFGUvP1K +uaBFwssybDlujMglmnXguoh9tiYRt2+3m7ArGqjcvBr6TZsSGKD3zO8IICIocj7RE2K Zmp2I14L+DNxESGf2khLfL4a6D7MIZRr4DbWHPuca9WS54x4tXOwI2OpmoK6hjhObM43 MFHhnLOoqd+m9LeMQAaRia0kw48rUGaJkgGXZOPTSAa5JiViuWsaI5GeMUhA2hYH61YJ 0nUnlEVhA9GXtEJBu1qrPOZ2ELJp4XpnfjKYv/Kzr8y7hm6/v/a7fwjr73wxI6UeACNV ejKw== 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=PG2ocAMiVixrDeygGSkU3xeZwD7YrFAmHiDnBCDK3aM=; b=UZl1M2mr9VPm/9WmW/oIjjvnAgNRzg5FcBLPMZ+F0JyNFmzFB+WDujcverqIMj72iF 6+GyaQnNXZPzoU9EyrYqWXuGtN/7l6e0jlmynUF55LK08O3di5OtUsjznQgO3YJ0PO6G gVBNYSQqD3NJqPwCTcaeI5D92AOrX5q895yiAEqUQ6+xekiZ2rfFIizVi54lIRGTIhdG 3dyFNtcf++JxcjtOYhX0pmZpOXKbtlFTtHPs26LXKyi7ZXdeivMyT4oyNr63OJp+N0z7 a8veNKGBD+jufyj87ntZ3yT3QZTyXF2KDE/F5EcEciB9X5gPpMGDEKS7Q2hxMb3Ds+o/ 5eEg== X-Gm-Message-State: AGRZ1gLOT5NEehheyQDRoVR8GWZB8STKunJNf68G4AKIylew8P7XlUHU GzuJOYuFMNbRDCaJuKyrxr0= X-Google-Smtp-Source: AJdET5fUAG3W+kWW6lAI5VHeSX5eFd7H00nE+t9QZao+yUkyNeyOUzBl9Cwp67wU1CKdwttlFzgmSA== X-Received: by 2002:a17:902:396a:: with SMTP id e39-v6mr4062601plg.65.1541743668182; Thu, 08 Nov 2018 22:07:48 -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 c70-v6sm6620722pfg.97.2018.11.08.22.07.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 22:07:47 -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 v7 03/17] of: overlay: add missing of_node_get() in __of_attach_node_sysfs Date: Thu, 8 Nov 2018 22:05:51 -0800 Message-Id: <1541743565-23163-4-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> References: <1541743565-23163-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. This commit 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 commit will fix the leak. Tested-by: Alan Tull Acked-by: Michael Ellerman (powerpc) Signed-off-by: Frank Rowand --- 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); }