2021-02-25 10:00:30

by Yang Li

[permalink] [raw]
Subject: [PATCH] pinctrl: ingenic: add missing call to of_node_put()

In one of the error paths of the for_each_child_of_node() loop in
ingenic_gpio_probe, add missing call to of_node_put().

Fix the following coccicheck warning:
./drivers/pinctrl/pinctrl-ingenic.c:2485:1-23: WARNING: Function
"for_each_child_of_node" should have of_node_put() before return around
line 2489.

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Yang Li <[email protected]>
---
drivers/pinctrl/pinctrl-ingenic.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index f274612..b7294a2 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -2486,6 +2486,7 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
if (of_match_node(ingenic_gpio_of_match, node)) {
err = ingenic_gpio_probe(jzpc, node);
if (err)
+ of_node_put(node);
return err;
}
}
--
1.8.3.1


2021-02-25 11:49:39

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: ingenic: add missing call to of_node_put()

Hi Yang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pinctrl/devel]
[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/pinctrl-ingenic-add-missing-call-to-of_node_put/20210225-172351
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
config: powerpc64-randconfig-r002-20210225 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a921aaf789912d981cbb2036bdc91ad7289e1523)
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
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/a13ac5c50a5b918ce628d5c61cf4b4f9a79759c2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yang-Li/pinctrl-ingenic-add-missing-call-to-of_node_put/20210225-172351
git checkout a13ac5c50a5b918ce628d5c61cf4b4f9a79759c2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/pinctrl/pinctrl-ingenic.c:2490:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
return err;
^
drivers/pinctrl/pinctrl-ingenic.c:2488:4: note: previous statement is here
if (err)
^
1 warning generated.

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for HOTPLUG_CPU
Depends on SMP && (PPC_PSERIES || PPC_PMAC || PPC_POWERNV || FSL_SOC_BOOKE
Selected by
- PM_SLEEP_SMP && SMP && (ARCH_SUSPEND_POSSIBLE || ARCH_HIBERNATION_POSSIBLE && PM_SLEEP


vim +/if +2490 drivers/pinctrl/pinctrl-ingenic.c

e72394e2ea196a Paul Cercueil 2018-08-21 2393
4717b11f80cf81 Paul Cercueil 2018-08-21 2394 static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
b5c23aa4653796 Paul Cercueil 2017-05-12 2395 {
b5c23aa4653796 Paul Cercueil 2017-05-12 2396 struct device *dev = &pdev->dev;
b5c23aa4653796 Paul Cercueil 2017-05-12 2397 struct ingenic_pinctrl *jzpc;
b5c23aa4653796 Paul Cercueil 2017-05-12 2398 struct pinctrl_desc *pctl_desc;
b5c23aa4653796 Paul Cercueil 2017-05-12 2399 void __iomem *base;
b5c23aa4653796 Paul Cercueil 2017-05-12 2400 const struct ingenic_chip_info *chip_info;
e72394e2ea196a Paul Cercueil 2018-08-21 2401 struct device_node *node;
b5c23aa4653796 Paul Cercueil 2017-05-12 2402 unsigned int i;
b5c23aa4653796 Paul Cercueil 2017-05-12 2403 int err;
b5c23aa4653796 Paul Cercueil 2017-05-12 2404
9aa351784e6962 Paul Cercueil 2020-12-13 2405 chip_info = of_device_get_match_data(dev);
9aa351784e6962 Paul Cercueil 2020-12-13 2406 if (!chip_info) {
9aa351784e6962 Paul Cercueil 2020-12-13 2407 dev_err(dev, "Unsupported SoC\n");
9aa351784e6962 Paul Cercueil 2020-12-13 2408 return -EINVAL;
9aa351784e6962 Paul Cercueil 2020-12-13 2409 }
9aa351784e6962 Paul Cercueil 2020-12-13 2410
b5c23aa4653796 Paul Cercueil 2017-05-12 2411 jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
b5c23aa4653796 Paul Cercueil 2017-05-12 2412 if (!jzpc)
b5c23aa4653796 Paul Cercueil 2017-05-12 2413 return -ENOMEM;
b5c23aa4653796 Paul Cercueil 2017-05-12 2414
94f7a2cb42bf7a Paul Cercueil 2020-01-07 2415 base = devm_platform_ioremap_resource(pdev, 0);
119fcf47fdb7c6 Wei Yongjun 2018-01-17 2416 if (IS_ERR(base))
b5c23aa4653796 Paul Cercueil 2017-05-12 2417 return PTR_ERR(base);
b5c23aa4653796 Paul Cercueil 2017-05-12 2418
b5c23aa4653796 Paul Cercueil 2017-05-12 2419 jzpc->map = devm_regmap_init_mmio(dev, base,
b5c23aa4653796 Paul Cercueil 2017-05-12 2420 &ingenic_pinctrl_regmap_config);
b5c23aa4653796 Paul Cercueil 2017-05-12 2421 if (IS_ERR(jzpc->map)) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2422 dev_err(dev, "Failed to create regmap\n");
b5c23aa4653796 Paul Cercueil 2017-05-12 2423 return PTR_ERR(jzpc->map);
b5c23aa4653796 Paul Cercueil 2017-05-12 2424 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2425
b5c23aa4653796 Paul Cercueil 2017-05-12 2426 jzpc->dev = dev;
9aa351784e6962 Paul Cercueil 2020-12-13 2427 jzpc->info = chip_info;
b5c23aa4653796 Paul Cercueil 2017-05-12 2428
b5c23aa4653796 Paul Cercueil 2017-05-12 2429 pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
b5c23aa4653796 Paul Cercueil 2017-05-12 2430 if (!pctl_desc)
b5c23aa4653796 Paul Cercueil 2017-05-12 2431 return -ENOMEM;
b5c23aa4653796 Paul Cercueil 2017-05-12 2432
b5c23aa4653796 Paul Cercueil 2017-05-12 2433 /* fill in pinctrl_desc structure */
b5c23aa4653796 Paul Cercueil 2017-05-12 2434 pctl_desc->name = dev_name(dev);
b5c23aa4653796 Paul Cercueil 2017-05-12 2435 pctl_desc->owner = THIS_MODULE;
b5c23aa4653796 Paul Cercueil 2017-05-12 2436 pctl_desc->pctlops = &ingenic_pctlops;
b5c23aa4653796 Paul Cercueil 2017-05-12 2437 pctl_desc->pmxops = &ingenic_pmxops;
b5c23aa4653796 Paul Cercueil 2017-05-12 2438 pctl_desc->confops = &ingenic_confops;
b5c23aa4653796 Paul Cercueil 2017-05-12 2439 pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
a86854d0c599b3 Kees Cook 2018-06-12 2440 pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
a86854d0c599b3 Kees Cook 2018-06-12 2441 pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
b5c23aa4653796 Paul Cercueil 2017-05-12 2442 if (!jzpc->pdesc)
b5c23aa4653796 Paul Cercueil 2017-05-12 2443 return -ENOMEM;
b5c23aa4653796 Paul Cercueil 2017-05-12 2444
b5c23aa4653796 Paul Cercueil 2017-05-12 2445 for (i = 0; i < pctl_desc->npins; i++) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2446 jzpc->pdesc[i].number = i;
b5c23aa4653796 Paul Cercueil 2017-05-12 2447 jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
b5c23aa4653796 Paul Cercueil 2017-05-12 2448 'A' + (i / PINS_PER_GPIO_CHIP),
b5c23aa4653796 Paul Cercueil 2017-05-12 2449 i % PINS_PER_GPIO_CHIP);
b5c23aa4653796 Paul Cercueil 2017-05-12 2450 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2451
b5c23aa4653796 Paul Cercueil 2017-05-12 2452 jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
e7f4c4bf99ad5e Dan Carpenter 2017-06-14 2453 if (IS_ERR(jzpc->pctl)) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2454 dev_err(dev, "Failed to register pinctrl\n");
e7f4c4bf99ad5e Dan Carpenter 2017-06-14 2455 return PTR_ERR(jzpc->pctl);
b5c23aa4653796 Paul Cercueil 2017-05-12 2456 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2457
b5c23aa4653796 Paul Cercueil 2017-05-12 2458 for (i = 0; i < chip_info->num_groups; i++) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2459 const struct group_desc *group = &chip_info->groups[i];
b5c23aa4653796 Paul Cercueil 2017-05-12 2460
b5c23aa4653796 Paul Cercueil 2017-05-12 2461 err = pinctrl_generic_add_group(jzpc->pctl, group->name,
b5c23aa4653796 Paul Cercueil 2017-05-12 2462 group->pins, group->num_pins, group->data);
823dd71f58eb21 Paul Burton 2018-08-25 2463 if (err < 0) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2464 dev_err(dev, "Failed to register group %s\n",
b5c23aa4653796 Paul Cercueil 2017-05-12 2465 group->name);
b5c23aa4653796 Paul Cercueil 2017-05-12 2466 return err;
b5c23aa4653796 Paul Cercueil 2017-05-12 2467 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2468 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2469
b5c23aa4653796 Paul Cercueil 2017-05-12 2470 for (i = 0; i < chip_info->num_functions; i++) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2471 const struct function_desc *func = &chip_info->functions[i];
b5c23aa4653796 Paul Cercueil 2017-05-12 2472
b5c23aa4653796 Paul Cercueil 2017-05-12 2473 err = pinmux_generic_add_function(jzpc->pctl, func->name,
b5c23aa4653796 Paul Cercueil 2017-05-12 2474 func->group_names, func->num_group_names,
b5c23aa4653796 Paul Cercueil 2017-05-12 2475 func->data);
823dd71f58eb21 Paul Burton 2018-08-25 2476 if (err < 0) {
b5c23aa4653796 Paul Cercueil 2017-05-12 2477 dev_err(dev, "Failed to register function %s\n",
b5c23aa4653796 Paul Cercueil 2017-05-12 2478 func->name);
b5c23aa4653796 Paul Cercueil 2017-05-12 2479 return err;
b5c23aa4653796 Paul Cercueil 2017-05-12 2480 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2481 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2482
b5c23aa4653796 Paul Cercueil 2017-05-12 2483 dev_set_drvdata(dev, jzpc->map);
b5c23aa4653796 Paul Cercueil 2017-05-12 2484
e72394e2ea196a Paul Cercueil 2018-08-21 2485 for_each_child_of_node(dev->of_node, node) {
e72394e2ea196a Paul Cercueil 2018-08-21 2486 if (of_match_node(ingenic_gpio_of_match, node)) {
e72394e2ea196a Paul Cercueil 2018-08-21 2487 err = ingenic_gpio_probe(jzpc, node);
e72394e2ea196a Paul Cercueil 2018-08-21 2488 if (err)
a13ac5c50a5b91 Yang Li 2021-02-25 2489 of_node_put(node);
b5c23aa4653796 Paul Cercueil 2017-05-12 @2490 return err;
b5c23aa4653796 Paul Cercueil 2017-05-12 2491 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2492 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2493
b5c23aa4653796 Paul Cercueil 2017-05-12 2494 return 0;
b5c23aa4653796 Paul Cercueil 2017-05-12 2495 }
b5c23aa4653796 Paul Cercueil 2017-05-12 2496

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (9.95 kB)
.config.gz (29.49 kB)
Download all attachments

2021-03-04 09:08:45

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: ingenic: add missing call to of_node_put()

On Thu, Feb 25, 2021 at 10:15 AM Yang Li <[email protected]> wrote:

> In one of the error paths of the for_each_child_of_node() loop in
> ingenic_gpio_probe, add missing call to of_node_put().
>
> Fix the following coccicheck warning:
> ./drivers/pinctrl/pinctrl-ingenic.c:2485:1-23: WARNING: Function
> "for_each_child_of_node" should have of_node_put() before return around
> line 2489.
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Yang Li <[email protected]>

Patch applied!

Yours,
Linus Walleij