* [PATCH] of/address: Fix of_node memory leak in of_dma_is_coherent
@ 2020-11-10 2:28 Evan Nimmo
2020-11-11 19:07 ` Rob Herring
0 siblings, 1 reply; 2+ messages in thread
From: Evan Nimmo @ 2020-11-10 2:28 UTC (permalink / raw)
To: frowand.list, robh+dt; +Cc: devicetree, linux-kernel, Evan Nimmo
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@alliedtelesis.co.nz>
---
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;
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);
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] of/address: Fix of_node memory leak in of_dma_is_coherent
2020-11-10 2:28 [PATCH] of/address: Fix of_node memory leak in of_dma_is_coherent Evan Nimmo
@ 2020-11-11 19:07 ` Rob Herring
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2020-11-11 19:07 UTC (permalink / raw)
To: Evan Nimmo; +Cc: linux-kernel, frowand.list, robh+dt, devicetree
On Tue, 10 Nov 2020 15:28:25 +1300, Evan Nimmo wrote:
> 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@alliedtelesis.co.nz>
> ---
> drivers/of/address.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-11 19:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 2:28 [PATCH] of/address: Fix of_node memory leak in of_dma_is_coherent Evan Nimmo
2020-11-11 19:07 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).