Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: Add missing of_node_put()

of_find_node_by_name() returns a node pointer with refcount incremented, use
of_node_put() on it when done.

of_find_node_by_name() will call of_node_put() against from parameter,
thus we also need to call of_node_get(from) before calling
of_find_node_by_name().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
c92f5dd2 9c9588a7

+26 -11
+2 -1
drivers/regulator/88pm8607.c
··· 372 372 struct regulator_config *config) 373 373 { 374 374 struct device_node *nproot, *np; 375 - nproot = pdev->dev.parent->of_node; 375 + nproot = of_node_get(pdev->dev.parent->of_node); 376 376 if (!nproot) 377 377 return -ENODEV; 378 378 nproot = of_find_node_by_name(nproot, "regulators"); ··· 388 388 break; 389 389 } 390 390 } 391 + of_node_put(nproot); 391 392 return 0; 392 393 } 393 394 #else
+3 -2
drivers/regulator/da9052-regulator.c
··· 395 395 config.init_data = pdata->regulators[pdev->id]; 396 396 } else { 397 397 #ifdef CONFIG_OF 398 - struct device_node *nproot = da9052->dev->of_node; 399 - struct device_node *np; 398 + struct device_node *nproot, *np; 400 399 400 + nproot = of_node_get(da9052->dev->of_node); 401 401 if (!nproot) 402 402 return -ENODEV; 403 403 ··· 414 414 break; 415 415 } 416 416 } 417 + of_node_put(nproot); 417 418 #endif 418 419 } 419 420
+4 -3
drivers/regulator/max8907-regulator.c
··· 224 224 225 225 static int max8907_regulator_parse_dt(struct platform_device *pdev) 226 226 { 227 - struct device_node *np = pdev->dev.parent->of_node; 228 - struct device_node *regulators; 227 + struct device_node *np, *regulators; 229 228 int ret; 230 229 231 - if (!pdev->dev.parent->of_node) 230 + np = of_node_get(pdev->dev.parent->of_node); 231 + if (!np) 232 232 return 0; 233 233 234 234 regulators = of_find_node_by_name(np, "regulators"); ··· 239 239 240 240 ret = of_regulator_match(&pdev->dev, regulators, max8907_matches, 241 241 ARRAY_SIZE(max8907_matches)); 242 + of_node_put(regulators); 242 243 if (ret < 0) { 243 244 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", 244 245 ret);
+2 -1
drivers/regulator/max8925-regulator.c
··· 252 252 { 253 253 struct device_node *nproot, *np; 254 254 int rcount; 255 - nproot = pdev->dev.parent->of_node; 255 + nproot = of_node_get(pdev->dev.parent->of_node); 256 256 if (!nproot) 257 257 return -ENODEV; 258 258 np = of_find_node_by_name(nproot, "regulators"); ··· 263 263 264 264 rcount = of_regulator_match(&pdev->dev, np, 265 265 &max8925_regulator_matches[ridx], 1); 266 + of_node_put(np); 266 267 if (rcount < 0) 267 268 return -ENODEV; 268 269 config->init_data = max8925_regulator_matches[ridx].init_data;
+3 -1
drivers/regulator/max8997.c
··· 960 960 struct max8997_regulator_data *rdata; 961 961 unsigned int i, dvs_voltage_nr = 1, ret; 962 962 963 - pmic_np = iodev->dev->of_node; 963 + pmic_np = of_node_get(iodev->dev->of_node); 964 964 if (!pmic_np) { 965 965 dev_err(&pdev->dev, "could not find pmic sub-node\n"); 966 966 return -ENODEV; ··· 980 980 rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * 981 981 pdata->num_regulators, GFP_KERNEL); 982 982 if (!rdata) { 983 + of_node_put(regulators_np); 983 984 dev_err(&pdev->dev, "could not allocate memory for regulator data\n"); 984 985 return -ENOMEM; 985 986 } ··· 1003 1002 rdata->reg_node = reg_np; 1004 1003 rdata++; 1005 1004 } 1005 + of_node_put(regulators_np); 1006 1006 1007 1007 if (of_get_property(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs", NULL)) 1008 1008 pdata->buck1_gpiodvs = true;
+6 -1
drivers/regulator/mc13xxx-regulator-core.c
··· 175 175 for_each_child_of_node(parent, child) 176 176 num++; 177 177 178 + of_node_put(parent); 178 179 return num; 179 180 } 180 181 EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt); ··· 198 197 199 198 data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators, 200 199 GFP_KERNEL); 201 - if (!data) 200 + if (!data) { 201 + of_node_put(parent); 202 202 return NULL; 203 + } 204 + 203 205 p = data; 204 206 205 207 for_each_child_of_node(parent, child) { ··· 221 217 } 222 218 } 223 219 } 220 + of_node_put(parent); 224 221 225 222 *num_parsed = parsed; 226 223 return data;
+2
drivers/regulator/palmas-regulator.c
··· 527 527 u32 prop; 528 528 int idx, ret; 529 529 530 + node = of_node_get(node); 530 531 regulators = of_find_node_by_name(node, "regulators"); 531 532 if (!regulators) { 532 533 dev_info(dev, "regulator node not found\n"); ··· 536 535 537 536 ret = of_regulator_match(dev, regulators, palmas_matches, 538 537 PALMAS_NUM_REGS); 538 + of_node_put(regulators); 539 539 if (ret < 0) { 540 540 dev_err(dev, "Error parsing regulator init data: %d\n", ret); 541 541 return;
+4 -2
drivers/regulator/tps65910-regulator.c
··· 964 964 { 965 965 struct tps65910_board *pmic_plat_data; 966 966 struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); 967 - struct device_node *np = pdev->dev.parent->of_node; 968 - struct device_node *regulators; 967 + struct device_node *np, *regulators; 969 968 struct of_regulator_match *matches; 970 969 unsigned int prop; 971 970 int idx = 0, ret, count; ··· 977 978 return NULL; 978 979 } 979 980 981 + np = of_node_get(pdev->dev.parent->of_node); 980 982 regulators = of_find_node_by_name(np, "regulators"); 981 983 if (!regulators) { 982 984 dev_err(&pdev->dev, "regulator node not found\n"); ··· 994 994 matches = tps65911_matches; 995 995 break; 996 996 default: 997 + of_node_put(regulators); 997 998 dev_err(&pdev->dev, "Invalid tps chip version\n"); 998 999 return NULL; 999 1000 } 1000 1001 1001 1002 ret = of_regulator_match(&pdev->dev, regulators, matches, count); 1003 + of_node_put(regulators); 1002 1004 if (ret < 0) { 1003 1005 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", 1004 1006 ret);