Linux-Devicetree Archive on
 help / color / Atom feed
From: Evan Nimmo <>
	Evan Nimmo <>
Subject: [PATCH] of/address: Fix of_node memory leak in of_dma_is_coherent
Date: Tue, 10 Nov 2020 15:28:25 +1300
Message-ID: <> (raw)

Commit dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on
powerpc") added a check to of_dma_is_coherent which returns early
if OF_DMA_DEFAULT_COHERENT is enabled. This results in the of_node_put()
being skipped causing a memory leak. Moved the of_node_get() below this
check so we now we only get the node if OF_DMA_DEFAULT_COHERENT is not

Fixes: dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on

Signed-off-by: Evan Nimmo <>
 drivers/of/address.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index eb9ab4f1e80b..1c3257a2d4e3 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -1034,11 +1034,13 @@ int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map)
 bool of_dma_is_coherent(struct device_node *np)
-	struct device_node *node = of_node_get(np);
+	struct device_node *node;
 		return true;
+	node = of_node_get(np);
 	while (node) {
 		if (of_property_read_bool(node, "dma-coherent")) {

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10  2:28 Evan Nimmo [this message]
2020-11-11 19:07 ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Devicetree Archive on

Archives are clonable:
	git clone --mirror linux-devicetree/git/0.git
	git clone --mirror linux-devicetree/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-devicetree linux-devicetree/ \
	public-inbox-index linux-devicetree

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone