]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/regulator/act8865-regulator.c
regulator: arizona-ldo1: Avoid potential memory leak reading init_data
[karo-tx-linux.git] / drivers / regulator / act8865-regulator.c
index a1cd0d4f82572424aad60054736be221db538304..7652477e6a9df95cb4b43c0ef7753886250371fd 100644 (file)
@@ -395,12 +395,6 @@ static int act8865_pdata_from_dt(struct device *dev,
        struct act8865_regulator_data *regulator;
        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) {
        case ACT8600:
                matches = act8600_matches;
@@ -419,6 +413,12 @@ static int act8865_pdata_from_dt(struct device *dev,
                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);
        of_node_put(np);
        if (matched <= 0)