of: fix of_node leak caused in of_find_node_opts_by_path
authorQi Hou <qi.hou@windriver.com>
Mon, 6 Feb 2017 04:55:19 +0000 (12:55 +0800)
committerRob Herring <robh@kernel.org>
Thu, 9 Feb 2017 15:11:30 +0000 (09:11 -0600)
commit0549bde0fcb11a95773e7dc4121738b9e653abf4
tree1363dcf0fe079815db273593ded5b08c7282847a
parent4b741bc35962ccf93b798a233512850c48c2646e
of: fix of_node leak caused in of_find_node_opts_by_path

During stepping down the tree, parent node is gotten first and its refcount is
increased with of_node_get() in __of_get_next_child(). Since it just being used
as tmp node, its refcount must be decreased with of_node_put() after traversing
its child nodes.

Or, its refcount will never be descreased to ZERO, then it will never be freed,
as well as other related memory blocks.

To fix this, decrease refcount of parent with of_node_put() after
__of_find_node_by_path().

Signed-off-by: Qi Hou <qi.hou@windriver.com>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/base.c