提交 c334940e 编写于 作者: R Russell King

component: fix missed cleanup in case of devres failure

In try_to_bring_up_master(), we tear down the master's component list
for each error case, except for devres group failure.  Fix this
oversight by making the code less prone to such mistakes.
Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 4c834452
...@@ -113,44 +113,44 @@ static void master_remove_components(struct master *master) ...@@ -113,44 +113,44 @@ static void master_remove_components(struct master *master)
static int try_to_bring_up_master(struct master *master, static int try_to_bring_up_master(struct master *master,
struct component *component) struct component *component)
{ {
int ret = 0; int ret;
if (!master->bound) { if (master->bound)
/* return 0;
* Search the list of components, looking for components that
* belong to this master, and attach them to the master.
*/
if (master->ops->add_components(master->dev, master)) {
/* Failed to find all components */
master_remove_components(master);
ret = 0;
goto out;
}
if (component && component->master != master) { /*
master_remove_components(master); * Search the list of components, looking for components that
ret = 0; * belong to this master, and attach them to the master.
goto out; */
} if (master->ops->add_components(master->dev, master)) {
/* Failed to find all components */
ret = 0;
goto out;
}
if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) { if (component && component->master != master) {
ret = -ENOMEM; ret = 0;
goto out; goto out;
} }
/* Found all components */ if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) {
ret = master->ops->bind(master->dev); ret = -ENOMEM;
if (ret < 0) { goto out;
devres_release_group(master->dev, NULL); }
dev_info(master->dev, "master bind failed: %d\n", ret);
master_remove_components(master);
goto out;
}
master->bound = true; /* Found all components */
ret = 1; ret = master->ops->bind(master->dev);
if (ret < 0) {
devres_release_group(master->dev, NULL);
dev_info(master->dev, "master bind failed: %d\n", ret);
goto out;
} }
master->bound = true;
return 1;
out: out:
master_remove_components(master);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册