提交 99737ebd 编写于 作者: E Evan Nimmo 提交者: Yang Yingliang

of/address: Fix of_node memory leak in of_dma_is_coherent

[ Upstream commit a5bea04f ]

Commit dabf6b36 ("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: dabf6b36 ("of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc")
Signed-off-by: NEvan Nimmo <evan.nimmo@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20201110022825.30895-1-evan.nimmo@alliedtelesis.co.nzSigned-off-by: NRob Herring <robh@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 20ae3415
...@@ -975,11 +975,13 @@ EXPORT_SYMBOL_GPL(of_dma_get_range); ...@@ -975,11 +975,13 @@ EXPORT_SYMBOL_GPL(of_dma_get_range);
*/ */
bool of_dma_is_coherent(struct device_node *np) 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)) if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
return true; return true;
node = of_node_get(np);
while (node) { while (node) {
if (of_property_read_bool(node, "dma-coherent")) { if (of_property_read_bool(node, "dma-coherent")) {
of_node_put(node); of_node_put(node);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册