1 From 7aded8716f0ec10dd01f44b0dff5b216f3333189 Mon Sep 17 00:00:00 2001
2 From: Julia Lawall <Julia.Lawall@lip6.fr>
3 Date: Sun, 13 Jan 2019 09:47:42 +0100
4 Subject: drm/imx: imx-ldb: add missing of_node_puts
6 [ Upstream commit aa3312012f103f91f123600bbf768b11c8f431bc ]
8 The device node iterators perform an of_node_get on each
9 iteration, so a jump out of the loop requires an of_node_put.
11 Move the initialization channel->child = child; down to just
12 before the call to imx_ldb_register so that intervening failures
13 don't need to clear it. Add a label at the end of the function to
14 do all the of_node_puts.
16 The semantic patch that finds part of this problem is as follows
17 (http://coccinelle.lip6.fr):
22 local idexpression child;
23 iterator name for_each_child_of_node;
26 for_each_child_of_node(root, child) {
27 ... when != of_node_put(child)
38 Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
39 Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
40 Signed-off-by: Sasha Levin <sashal@kernel.org>
42 drivers/gpu/drm/imx/imx-ldb.c | 25 +++++++++++++++++--------
43 1 file changed, 17 insertions(+), 8 deletions(-)
45 diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
46 index dd5312b02a8d..4f2e6c7e04c1 100644
47 --- a/drivers/gpu/drm/imx/imx-ldb.c
48 +++ b/drivers/gpu/drm/imx/imx-ldb.c
49 @@ -652,8 +652,10 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
52 ret = of_property_read_u32(child, "reg", &i);
53 - if (ret || i < 0 || i > 1)
55 + if (ret || i < 0 || i > 1) {
60 if (!of_device_is_available(child))
62 @@ -666,7 +668,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
63 channel = &imx_ldb->channel[i];
64 channel->ldb = imx_ldb;
66 - channel->child = child;
69 * The output port is port@4 with an external 4-port mux or
70 @@ -676,13 +677,13 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
71 imx_ldb->lvds_mux ? 4 : 2, 0,
72 &channel->panel, &channel->bridge);
73 if (ret && ret != -ENODEV)
77 /* panel ddc only if there is no bridge */
78 if (!channel->bridge) {
79 ret = imx_ldb_panel_ddc(dev, channel, child);
85 bus_format = of_get_bus_format(dev, child);
86 @@ -698,18 +699,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
88 dev_err(dev, "could not determine data mapping: %d\n",
94 channel->bus_format = bus_format;
95 + channel->child = child;
97 ret = imx_ldb_register(drm, channel);
101 + channel->child = NULL;
106 dev_set_drvdata(dev, imx_ldb);
111 + of_node_put(child);
115 static void imx_ldb_unbind(struct device *dev, struct device *master,