This is a note to let you know that I've just added the patch titled of/address: Fix of_node memory leak in of_dma_is_coherent to the 5.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: of-address-fix-of_node-memory-leak-in-of_dma_is_cohe.patch and it can be found in the queue-5.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 5560234426e0974ae75609b4fdafb24391add8fd Author: Evan Nimmo <evan.nimmo@xxxxxxxxxxxxxxxxxxx> Date: Tue Nov 10 15:28:25 2020 +1300 of/address: Fix of_node memory leak in of_dma_is_coherent [ Upstream commit a5bea04fcc0b3c0aec71ee1fd58fd4ff7ee36177 ] 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 enabled. Fixes: dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc") Signed-off-by: Evan Nimmo <evan.nimmo@xxxxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20201110022825.30895-1-evan.nimmo@xxxxxxxxxxxxxxxxxxx Signed-off-by: Rob Herring <robh@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/of/address.c b/drivers/of/address.c index da4f7341323f2..37ac311843090 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -1043,11 +1043,13 @@ out: */ bool of_dma_is_coherent(struct device_node *np) { - struct device_node *node = of_node_get(np); + struct device_node *node; if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT)) return true; + node = of_node_get(np); + while (node) { if (of_property_read_bool(node, "dma-coherent")) { of_node_put(node);