Re: [PATCH] regulator: add missing call to of_node_put()

From: kernel test robot
Date: Thu Feb 25 2021 - 08:41:01 EST


Hi Yang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on regulator/for-next]
[also build test WARNING on v5.11 next-20210225]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Yang-Li/regulator-add-missing-call-to-of_node_put/20210225-171554
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: riscv-allmodconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1e86ace1b41a7e1cd7f89e0ceba95768d4e5760a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yang-Li/regulator-add-missing-call-to-of_node_put/20210225-171554
git checkout 1e86ace1b41a7e1cd7f89e0ceba95768d4e5760a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/regulator/scmi-regulator.c: In function 'scmi_regulator_probe':
>> drivers/regulator/scmi-regulator.c:346:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
346 | if (ret == -ENOMEM)
| ^~
drivers/regulator/scmi-regulator.c:348:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
348 | return ret;
| ^~~~~~


vim +/if +346 drivers/regulator/scmi-regulator.c

0fbeae70ee7ce98e Cristian Marussi 2020-11-23 298
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 299 static int scmi_regulator_probe(struct scmi_device *sdev)
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 300 {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 301 int d, ret, num_doms;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 302 struct device_node *np, *child;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 303 const struct scmi_handle *handle = sdev->handle;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 304 struct scmi_regulator_info *rinfo;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 305
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 306 if (!handle || !handle->voltage_ops)
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 307 return -ENODEV;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 308
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 309 num_doms = handle->voltage_ops->num_domains_get(handle);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 310 if (num_doms <= 0) {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 311 if (!num_doms) {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 312 dev_err(&sdev->dev,
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 313 "number of voltage domains invalid\n");
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 314 num_doms = -EINVAL;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 315 } else {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 316 dev_err(&sdev->dev,
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 317 "failed to get voltage domains - err:%d\n",
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 318 num_doms);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 319 }
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 320
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 321 return num_doms;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 322 }
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 323
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 324 rinfo = devm_kzalloc(&sdev->dev, sizeof(*rinfo), GFP_KERNEL);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 325 if (!rinfo)
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 326 return -ENOMEM;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 327
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 328 /* Allocate pointers array for all possible domains */
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 329 rinfo->sregv = devm_kcalloc(&sdev->dev, num_doms,
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 330 sizeof(void *), GFP_KERNEL);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 331 if (!rinfo->sregv)
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 332 return -ENOMEM;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 333
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 334 rinfo->num_doms = num_doms;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 335
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 336 /*
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 337 * Start collecting into rinfo->sregv possibly good SCMI Regulators as
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 338 * described by a well-formed DT entry and associated with an existing
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 339 * plausible SCMI Voltage Domain number, all belonging to this SCMI
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 340 * platform instance node (handle->dev->of_node).
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 341 */
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 342 np = of_find_node_by_name(handle->dev->of_node, "regulators");
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 343 for_each_child_of_node(np, child) {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 344 ret = process_scmi_regulator_of_node(sdev, child, rinfo);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 345 /* abort on any mem issue */
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 @346 if (ret == -ENOMEM)
1e86ace1b41a7e1c Yang Li 2021-02-25 347 of_node_put(child);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 348 return ret;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 349 }
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 350
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 351 /*
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 352 * Register a regulator for each valid regulator-DT-entry that we
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 353 * can successfully reach via SCMI and has a valid associated voltage
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 354 * domain.
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 355 */
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 356 for (d = 0; d < num_doms; d++) {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 357 struct scmi_regulator *sreg = rinfo->sregv[d];
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 358
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 359 /* Skip empty slots */
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 360 if (!sreg)
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 361 continue;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 362
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 363 ret = scmi_regulator_common_init(sreg);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 364 /* Skip invalid voltage domains */
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 365 if (ret)
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 366 continue;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 367
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 368 sreg->rdev = devm_regulator_register(&sdev->dev, &sreg->desc,
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 369 &sreg->conf);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 370 if (IS_ERR(sreg->rdev)) {
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 371 sreg->rdev = NULL;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 372 continue;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 373 }
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 374
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 375 dev_info(&sdev->dev,
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 376 "Regulator %s registered for domain [%d]\n",
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 377 sreg->desc.name, sreg->id);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 378 }
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 379
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 380 dev_set_drvdata(&sdev->dev, rinfo);
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 381
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 382 return 0;
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 383 }
0fbeae70ee7ce98e Cristian Marussi 2020-11-23 384

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip