From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH] device property: preserve usecount for node passed to of_fwnode_graph_get_port_parent() Date: Mon, 21 Aug 2017 14:51:07 +0200 Message-ID: <20170821125107.20746-1-niklas.soderlund+renesas@ragnatech.se> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Sender: linux-media-owner@vger.kernel.org To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: Sakari Ailus , Kieran Bingham , linux-renesas-soc@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= List-Id: devicetree@vger.kernel.org Using CONFIG_OF_DYNAMIC=y uncovered an imbalance in the usecount of the node being passed to of_fwnode_graph_get_port_parent(). Preserve the usecount just like it is done in of_graph_get_port_parent(). Fixes: 3b27d00e7b6d7c88 ("device property: Move fwnode graph ops to firmware specific locations") Signed-off-by: Niklas Söderlund --- drivers/of/property.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index 067f9fab7b77c794..637dcb4833e2af60 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -922,6 +922,12 @@ of_fwnode_graph_get_port_parent(struct fwnode_handle *fwnode) { struct device_node *np; + /* + * Preserve usecount for passed in node as of_get_next_parent() + * will do of_node_put() on it. + */ + of_node_get(to_of_node(fwnode)); + /* Get the parent of the port */ np = of_get_next_parent(to_of_node(fwnode)); if (!np) -- 2.14.0 For posterity here is the console log: OF: ERROR: Bad of_node_put() on /soc/i2c@e66d8000/gmsl-deserializer@1/ports/port@4 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc4-00418-g32df6aeea9a6f626 #14 Hardware name: Renesas Salvator-X board based on r8a7795 ES1.x (DT) Call trace: [] dump_backtrace+0x0/0x238 [] show_stack+0x14/0x20 [] dump_stack+0x9c/0xbc [] of_node_release+0xb8/0xc0 [] kobject_put+0x84/0xf0 [] of_node_put+0x14/0x28 [] of_fwnode_put+0x24/0x40 [] fwnode_graph_get_port_parent+0x60/0xb0 [] match_fwnode+0x2c/0x88 [] v4l2_async_belongs+0x78/0x120 [] v4l2_async_notifier_register+0x11c/0x1d8 [] v4l2_async_test_notify+0x58/0x160 [] v4l2_async_notifier_register+0xf0/0x1d8 [] rcar_vin_probe+0x65c/0x718 [] platform_drv_probe+0x58/0xb8 [] driver_probe_device+0x22c/0x2d8 [] __driver_attach+0xbc/0xc0 [] bus_for_each_dev+0x4c/0x98 [] driver_attach+0x20/0x28 [] bus_add_driver+0x1b8/0x228 [] driver_register+0x60/0xf8 [] __platform_driver_register+0x40/0x48 [] rcar_vin_driver_init+0x18/0x20 [] do_one_initcall+0x80/0x110 [] kernel_init_freeable+0x188/0x224 [] kernel_init+0x10/0x100 [] ret_from_fork+0x10/0x50