提交 aa331201 编写于 作者: J Julia Lawall 提交者: Philipp Zabel

drm/imx: imx-ldb: add missing of_node_puts

The device node iterators perform an of_node_get on each
iteration, so a jump out of the loop requires an of_node_put.

Move the initialization channel->child = child; down to just
before the call to imx_ldb_register so that intervening failures
don't need to clear it.  Add a label at the end of the function to
do all the of_node_puts.

The semantic patch that finds part of this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
*  return ...;
)
   ...
 }
// </smpl>
Signed-off-by: NJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: NPhilipp Zabel <p.zabel@pengutronix.de>
上级 2c0408dd
...@@ -643,8 +643,10 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) ...@@ -643,8 +643,10 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
int bus_format; int bus_format;
ret = of_property_read_u32(child, "reg", &i); ret = of_property_read_u32(child, "reg", &i);
if (ret || i < 0 || i > 1) if (ret || i < 0 || i > 1) {
return -EINVAL; ret = -EINVAL;
goto free_child;
}
if (!of_device_is_available(child)) if (!of_device_is_available(child))
continue; continue;
...@@ -657,7 +659,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) ...@@ -657,7 +659,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
channel = &imx_ldb->channel[i]; channel = &imx_ldb->channel[i];
channel->ldb = imx_ldb; channel->ldb = imx_ldb;
channel->chno = i; channel->chno = i;
channel->child = child;
/* /*
* The output port is port@4 with an external 4-port mux or * The output port is port@4 with an external 4-port mux or
...@@ -667,13 +668,13 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) ...@@ -667,13 +668,13 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
imx_ldb->lvds_mux ? 4 : 2, 0, imx_ldb->lvds_mux ? 4 : 2, 0,
&channel->panel, &channel->bridge); &channel->panel, &channel->bridge);
if (ret && ret != -ENODEV) if (ret && ret != -ENODEV)
return ret; goto free_child;
/* panel ddc only if there is no bridge */ /* panel ddc only if there is no bridge */
if (!channel->bridge) { if (!channel->bridge) {
ret = imx_ldb_panel_ddc(dev, channel, child); ret = imx_ldb_panel_ddc(dev, channel, child);
if (ret) if (ret)
return ret; goto free_child;
} }
bus_format = of_get_bus_format(dev, child); bus_format = of_get_bus_format(dev, child);
...@@ -689,18 +690,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) ...@@ -689,18 +690,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
if (bus_format < 0) { if (bus_format < 0) {
dev_err(dev, "could not determine data mapping: %d\n", dev_err(dev, "could not determine data mapping: %d\n",
bus_format); bus_format);
return bus_format; ret = bus_format;
goto free_child;
} }
channel->bus_format = bus_format; channel->bus_format = bus_format;
channel->child = child;
ret = imx_ldb_register(drm, channel); ret = imx_ldb_register(drm, channel);
if (ret) if (ret) {
return ret; channel->child = NULL;
goto free_child;
}
} }
dev_set_drvdata(dev, imx_ldb); dev_set_drvdata(dev, imx_ldb);
return 0; return 0;
free_child:
of_node_put(child);
return ret;
} }
static void imx_ldb_unbind(struct device *dev, struct device *master, static void imx_ldb_unbind(struct device *dev, struct device *master,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册