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

Commit 842a8824 authored by Wei Yongjun's avatar Wei Yongjun Committed by Mark Brown
Browse files

regulator: act8865: Fix missing of_node_put() in act8865_pdata_from_dt()



This node pointer is returned by of_get_child_by_name() with
refcount incremented in this function. of_node_put() is missing
when exitting this function while invalid device type. Fix it
by move of_get_child_by_name() code after device type check.

Found by Coccinelle.

Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1a695a90
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -395,12 +395,6 @@ static int act8865_pdata_from_dt(struct device *dev,
	struct act8865_regulator_data *regulator;
	struct act8865_regulator_data *regulator;
	struct of_regulator_match *matches;
	struct of_regulator_match *matches;


	np = of_get_child_by_name(dev->of_node, "regulators");
	if (!np) {
		dev_err(dev, "missing 'regulators' subnode in DT\n");
		return -EINVAL;
	}

	switch (type) {
	switch (type) {
	case ACT8600:
	case ACT8600:
		matches = act8600_matches;
		matches = act8600_matches;
@@ -419,6 +413,12 @@ static int act8865_pdata_from_dt(struct device *dev,
		return -EINVAL;
		return -EINVAL;
	}
	}


	np = of_get_child_by_name(dev->of_node, "regulators");
	if (!np) {
		dev_err(dev, "missing 'regulators' subnode in DT\n");
		return -EINVAL;
	}

	matched = of_regulator_match(dev, np, matches, num_matches);
	matched = of_regulator_match(dev, np, matches, num_matches);
	of_node_put(np);
	of_node_put(np);
	if (matched <= 0)
	if (matched <= 0)