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

pinctrl: freescale: mxs: Fix refcount of child

of_get_next_child() will increase refcount of the returned node, need
use of_node_put() on it when done.

Per current implementation, 'child' will be override by
for_each_child_of_node(np, child), so use of_get_child_count to avoid
refcount leakage.

Fixes: 17723111e64f ("pinctrl: add pinctrl-mxs support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/20240504-pinctrl-cleanup-v2-18-26c5f2dc1181@nxp.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Peng Fan and committed by
Linus Walleij
7f500f20 d7f5120a

+2 -2
+2 -2
drivers/pinctrl/freescale/pinctrl-mxs.c
··· 413 413 int ret; 414 414 u32 val; 415 415 416 - child = of_get_next_child(np, NULL); 417 - if (!child) { 416 + val = of_get_child_count(np); 417 + if (val == 0) { 418 418 dev_err(&pdev->dev, "no group is defined\n"); 419 419 return -ENOENT; 420 420 }