of: of_node_get()/of_node_put() nodes held in phandle cache
authorFrank Rowand <frank.rowand@sony.com>
Tue, 18 Dec 2018 19:40:02 +0000 (11:40 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Jan 2019 08:51:10 +0000 (09:51 +0100)
commit1cb5a0333a5d2b3e79c318751d71a080a7869a88
tree9829a1d082f60d9b5014e7b7cf564c7fecbe0f44
parentdaa67bd5d1ec3398c0386c222502c26af7788c5d
of: of_node_get()/of_node_put() nodes held in phandle cache

commit b8a9ac1a5b99a2fcbed19fd29d2d59270c281a31 upstream.

The phandle cache contains struct device_node pointers.  The refcount
of the pointers was not incremented while in the cache, allowing use
after free error after kfree() of the node.  Add the proper increment
and decrement of the use count.

Fixes: 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()")
Cc: stable@vger.kernel.org # v4.17+
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/of/base.c