Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c334940e authored by Russell King's avatar Russell King
Browse files

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 4c834452
Loading
Loading
Loading
Loading
+31 −31
Original line number Original line Diff line number Diff line
@@ -113,22 +113,22 @@ 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)
		return 0;


	if (!master->bound) {
	/*
	/*
	 * Search the list of components, looking for components that
	 * Search the list of components, looking for components that
	 * belong to this master, and attach them to the master.
	 * belong to this master, and attach them to the master.
	 */
	 */
	if (master->ops->add_components(master->dev, master)) {
	if (master->ops->add_components(master->dev, master)) {
		/* Failed to find all components */
		/* Failed to find all components */
			master_remove_components(master);
		ret = 0;
		ret = 0;
		goto out;
		goto out;
	}
	}


	if (component && component->master != master) {
	if (component && component->master != master) {
			master_remove_components(master);
		ret = 0;
		ret = 0;
		goto out;
		goto out;
	}
	}
@@ -143,14 +143,14 @@ static int try_to_bring_up_master(struct master *master,
	if (ret < 0) {
	if (ret < 0) {
		devres_release_group(master->dev, NULL);
		devres_release_group(master->dev, NULL);
		dev_info(master->dev, "master bind failed: %d\n", ret);
		dev_info(master->dev, "master bind failed: %d\n", ret);
			master_remove_components(master);
		goto out;
		goto out;
	}
	}


	master->bound = true;
	master->bound = true;
		ret = 1;
	return 1;
	}

out:
out:
	master_remove_components(master);


	return ret;
	return ret;
}
}