2019-04-12 06:02:25

by Wen Yang

[permalink] [raw]
Subject: [PATCH 0/5] fix leaked of_node references in drivers/pinctrl

The call to of_get_cpu_node/of_find_compatible_node/of_parse_phandle...
returns a node pointer with refcount incremented thus it must be
explicitly decremented after the last usage.

We developed a coccinelle SmPL to detect drivers/pinctrl code and
found some issues.
This patch series fixes those issues.

Wen Yang (5):
pinctrl: pistachio: fix leaked of_node references
pinctrl: rockchip: fix leaked of_node references
pinctrl: st: fix leaked of_node references
pinctrl: samsung: fix leaked of_node references
pinctrl: zte: fix leaked of_node references

drivers/pinctrl/pinctrl-pistachio.c | 2 ++
drivers/pinctrl/pinctrl-rockchip.c | 1 +
drivers/pinctrl/pinctrl-st.c | 15 ++++++++++-----
drivers/pinctrl/samsung/pinctrl-exynos-arm.c | 1 +
drivers/pinctrl/zte/pinctrl-zx.c | 1 +
5 files changed, 15 insertions(+), 5 deletions(-)

--
2.9.5


2019-04-12 06:02:34

by Wen Yang

[permalink] [raw]
Subject: [PATCH 3/5] pinctrl: st: fix leaked of_node references

The call to of_get_child_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <[email protected]>
Cc: Patrice Chotard <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: [email protected]
Cc: [email protected] (open list)
---
drivers/pinctrl/pinctrl-st.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index e66af93..195b442 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1170,7 +1170,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
struct property *pp;
struct st_pinconf *conf;
struct device_node *pins;
- int i = 0, npins = 0, nr_props;
+ int i = 0, npins = 0, nr_props, ret = 0;

pins = of_get_child_by_name(np, "st,pins");
if (!pins)
@@ -1185,7 +1185,8 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
npins++;
} else {
pr_warn("Invalid st,pins in %pOFn node\n", np);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out_put_node;
}
}

@@ -1195,8 +1196,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
grp->pin_conf = devm_kcalloc(info->dev,
npins, sizeof(*conf), GFP_KERNEL);

- if (!grp->pins || !grp->pin_conf)
- return -ENOMEM;
+ if (!grp->pins || !grp->pin_conf) {
+ ret = -ENOMEM;
+ goto out_put_node;
+ }

/* <bank offset mux direction rt_type rt_delay rt_clk> */
for_each_property_of_node(pins, pp) {
@@ -1229,9 +1232,11 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
}
i++;
}
+
+out_put_node:
of_node_put(pins);

- return 0;
+ return ret;
}

static int st_pctl_parse_functions(struct device_node *np,
--
2.9.5

2019-04-12 06:02:39

by Wen Yang

[permalink] [raw]
Subject: [PATCH 4/5] pinctrl: samsung: fix leaked of_node references

The call to of_find_compatible_node returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:76:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:82:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Tomasz Figa <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Sylwester Nawrocki <[email protected]>
Cc: Kukjin Kim <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
drivers/pinctrl/samsung/pinctrl-exynos-arm.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
index 44c6b75..85ddf49 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
@@ -71,6 +71,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
}

clk_base = of_iomap(np, 0);
+ of_node_put(np);
if (!clk_base) {
pr_err("%s: failed to map clock registers\n", __func__);
return ERR_PTR(-EINVAL);
--
2.9.5

2019-04-12 06:02:45

by Wen Yang

[permalink] [raw]
Subject: [PATCH 1/5] pinctrl: pistachio: fix leaked of_node references

The call to of_get_child_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pinctrl/pinctrl-pistachio.c:1422:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1360, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/pinctrl/pinctrl-pistachio.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index aa5f949..5b0678f 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -1367,6 +1367,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
if (!of_find_property(child, "gpio-controller", NULL)) {
dev_err(pctl->dev,
"No gpio-controller property for bank %u\n", i);
+ of_node_put(child);
ret = -ENODEV;
goto err;
}
@@ -1374,6 +1375,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
irq = irq_of_parse_and_map(child, 0);
if (irq < 0) {
dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
+ of_node_put(child);
ret = irq;
goto err;
}
--
2.9.5

2019-04-12 06:03:51

by Wen Yang

[permalink] [raw]
Subject: [PATCH 2/5] pinctrl: rockchip: fix leaked of_node references

The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pinctrl/pinctrl-rockchip.c:3221:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3196, but without a corresponding object release within this function.
./drivers/pinctrl/pinctrl-rockchip.c:3223:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3196, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
drivers/pinctrl/pinctrl-rockchip.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 16bf21b..e22d387 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -3195,6 +3195,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,

node = of_parse_phandle(bank->of_node->parent,
"rockchip,pmu", 0);
+ of_node_put(node);
if (!node) {
if (of_address_to_resource(bank->of_node, 1, &res)) {
dev_err(info->dev, "cannot find IO resource for bank\n");
--
2.9.5

2019-04-12 06:04:20

by Wen Yang

[permalink] [raw]
Subject: [PATCH 5/5] pinctrl: zte: fix leaked of_node references

The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pinctrl/zte/pinctrl-zx.c:415:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
./drivers/pinctrl/zte/pinctrl-zx.c:422:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
./drivers/pinctrl/zte/pinctrl-zx.c:436:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
./drivers/pinctrl/zte/pinctrl-zx.c:444:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
./drivers/pinctrl/zte/pinctrl-zx.c:448:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Jun Nie <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/pinctrl/zte/pinctrl-zx.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/zte/pinctrl-zx.c b/drivers/pinctrl/zte/pinctrl-zx.c
index caa44dd..3cb6930 100644
--- a/drivers/pinctrl/zte/pinctrl-zx.c
+++ b/drivers/pinctrl/zte/pinctrl-zx.c
@@ -411,6 +411,7 @@ int zx_pinctrl_init(struct platform_device *pdev,
}

zpctl->aux_base = of_iomap(np, 0);
+ of_node_put(np);
if (!zpctl->aux_base)
return -ENOMEM;

--
2.9.5

2019-04-12 07:14:02

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 4/5] pinctrl: samsung: fix leaked of_node references

On Fri, 12 Apr 2019 at 08:01, Wen Yang <[email protected]> wrote:
>
> The call to of_find_compatible_node returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:76:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
> ./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:82:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2019-04-12 08:09:33

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH 2/5] pinctrl: rockchip: fix leaked of_node references

Hi,

Am Freitag, 12. April 2019, 08:02:20 CEST schrieb Wen Yang:
> The call to of_parse_phandle returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/pinctrl-rockchip.c:3221:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3196, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-rockchip.c:3223:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3196, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Heiko Stuebner <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/pinctrl/pinctrl-rockchip.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 16bf21b..e22d387 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -3195,6 +3195,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
>
> node = of_parse_phandle(bank->of_node->parent,
> "rockchip,pmu", 0);
> + of_node_put(node);
> if (!node) {
> if (of_address_to_resource(bank->of_node, 1, &res)) {
> dev_err(info->dev, "cannot find IO resource for bank\n");
>

hmm, the conditional does still use the node pointer, so the of_node_put
should probably be below the whole if clause?


Heiko



2019-04-12 09:00:12

by Patrice CHOTARD

[permalink] [raw]
Subject: Re: [PATCH 3/5] pinctrl: st: fix leaked of_node references

Hi Wen

On 4/12/19 8:02 AM, Wen Yang wrote:
> The call to of_get_child_by_name returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Patrice Chotard <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: [email protected]
> Cc: [email protected] (open list)
> ---
> drivers/pinctrl/pinctrl-st.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
> index e66af93..195b442 100644
> --- a/drivers/pinctrl/pinctrl-st.c
> +++ b/drivers/pinctrl/pinctrl-st.c
> @@ -1170,7 +1170,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
> struct property *pp;
> struct st_pinconf *conf;
> struct device_node *pins;
> - int i = 0, npins = 0, nr_props;
> + int i = 0, npins = 0, nr_props, ret = 0;
>
> pins = of_get_child_by_name(np, "st,pins");
> if (!pins)
> @@ -1185,7 +1185,8 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
> npins++;
> } else {
> pr_warn("Invalid st,pins in %pOFn node\n", np);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto out_put_node;
> }
> }
>
> @@ -1195,8 +1196,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
> grp->pin_conf = devm_kcalloc(info->dev,
> npins, sizeof(*conf), GFP_KERNEL);
>
> - if (!grp->pins || !grp->pin_conf)
> - return -ENOMEM;
> + if (!grp->pins || !grp->pin_conf) {
> + ret = -ENOMEM;
> + goto out_put_node;
> + }
>
> /* <bank offset mux direction rt_type rt_delay rt_clk> */
> for_each_property_of_node(pins, pp) {
> @@ -1229,9 +1232,11 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
> }
> i++;
> }
> +
> +out_put_node:
> of_node_put(pins);
>
> - return 0;
> + return ret;
> }
>
> static int st_pctl_parse_functions(struct device_node *np,
>

Reviewed-by: Patrice Chotard <[email protected]>

Thanks

2019-04-12 11:21:17

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH 2/5] pinctrl: rockchip: fix leaked of_node references

Hi,

Am Freitag, 12. April 2019, 10:45:29 CEST schrieb [email protected]:
> > > The call to of_parse_phandle returns a node pointer with refcount
> > > incremented thus it must be explicitly decremented after the last
> > > usage.
> > >
> > > Detected by coccinelle with the following warnings:
> > > ./drivers/pinctrl/pinctrl-rockchip.c:3221:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3196, but without a corresponding object release within this function.
> > > ./drivers/pinctrl/pinctrl-rockchip.c:3223:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 3196, but without a corresponding object release within this function.
> > >
> > > Signed-off-by: Wen Yang <[email protected]>
> > > Cc: Linus Walleij <[email protected]>
> > > Cc: Heiko Stuebner <[email protected]>
> > > Cc: [email protected]
> > > Cc: [email protected]
> > > Cc: [email protected]
> > > Cc: [email protected]
> > > ---
> > > drivers/pinctrl/pinctrl-rockchip.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> > > index 16bf21b..e22d387 100644
> > > --- a/drivers/pinctrl/pinctrl-rockchip.c
> > > +++ b/drivers/pinctrl/pinctrl-rockchip.c
> > > @@ -3195,6 +3195,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
> > >
> > > node = of_parse_phandle(bank->of_node->parent,
> > > "rockchip,pmu", 0);
> > > + of_node_put(node);
> > > if (!node) {
> > > if (of_address_to_resource(bank->of_node, 1, &res)) {
> > > dev_err(info->dev, "cannot find IO resource for bank\n");
> > >
> >
> > hmm, the conditional does still use the node pointer, so the of_node_put
> > should probably be below the whole if clause?
>
> Thank you for your comments.
>
> There may be two methods to fix this issue here.
> Method 1, Add of_node_put after the conditional statement:
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 16bf21b..5f822e6 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -3198,12 +3198,15 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
> if (!node) {
> if (of_address_to_resource(bank->of_node, 1, &res)) {
> dev_err(info->dev, "cannot find IO resource for bank\n");
> + of_node_put(node);
> return -ENOENT;
> }
>
> base = devm_ioremap_resource(info->dev, &res);
> - if (IS_ERR(base))
> + if (IS_ERR(base)) {
> + of_node_put(node);
> return PTR_ERR(base);
> + }
> rockchip_regmap_config.max_register =
> resource_size(&res) - 4;
> rockchip_regmap_config.name =
> @@ -3212,6 +3215,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
> base,
> &rockchip_regmap_config);
> }
> + of_node_put(node);
> }
>
> bank->irq = irq_of_parse_and_map(bank->of_node, 0)
>
> Method 2, Add of_node_put before conditional statement:
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 16bf21b..e22d387 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -3195,6 +3195,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
>
> node = of_parse_phandle(bank->of_node->parent,
> "rockchip,pmu", 0);
> + of_node_put(node);
> if (!node) {
> if (of_address_to_resource(bank->of_node, 1, &res)) {
> dev_err(info->dev, "cannot find IO resource for bank\n");
>
> Since we're just determining whether the node pointer is null, and don't need to dereference the node pointer.
> So if we use the Method 2, it might be a little bit simpler.
> Thanks.

personally I prefer to do it cleanly honoring the rules of using of_nodes.

So while your method 2 may make it simpler people possibly editing the
code later then need to remember that the node actually is already put
when it is checked (or possibly even used in some later patch)


Heiko


2019-04-14 13:17:27

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 1/5] pinctrl: pistachio: fix leaked of_node references

> @@ -1367,6 +1367,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
> if (!of_find_property(child, "gpio-controller", NULL)) {
> dev_err(pctl->dev,
> "No gpio-controller property for bank %u\n", i);
> + of_node_put(child);
> ret = -ENODEV;
> goto err;
> }
> @@ -1374,6 +1375,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
> irq = irq_of_parse_and_map(child, 0);
> if (irq < 0) {
> dev_err(pctl->dev, "No IRQ for bank %u: %d\n", i, irq);
> + of_node_put(child);
> ret = irq;
> goto err;
> }

Would you like to move such duplicate statements (and other function calls)
to additional jump targets for the desired exception handling?

Regards,
Markus

2019-04-16 05:57:37

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH 5/5] pinctrl: zte: fix leaked of_node references

On Fri, Apr 12, 2019 at 02:02:23PM +0800, Wen Yang wrote:
> The call to of_parse_phandle returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/zte/pinctrl-zx.c:415:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:422:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:436:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:444:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:448:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Jun Nie <[email protected]>
> Cc: Shawn Guo <[email protected]>

Acked-by: Shawn Guo <[email protected]>

2019-04-23 09:02:29

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 4/5] pinctrl: samsung: fix leaked of_node references

On Fri, Apr 12, 2019 at 8:01 AM Wen Yang <[email protected]> wrote:

> The call to of_find_compatible_node returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:76:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
> ./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:82:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Tomasz Figa <[email protected]>
> Cc: Krzysztof Kozlowski <[email protected]>
> Cc: Sylwester Nawrocki <[email protected]>
> Cc: Kukjin Kim <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]

Patch applied with Krzysztof's ACK.

Yours,
Linus Walleij

2019-04-23 09:05:02

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 3/5] pinctrl: st: fix leaked of_node references

On Fri, Apr 12, 2019 at 8:01 AM Wen Yang <[email protected]> wrote:

> The call to of_get_child_by_name returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-st.c:1188:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
> ./drivers/pinctrl/pinctrl-st.c:1199:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1175, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Patrice Chotard <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: [email protected]
> Cc: [email protected] (open list)

Patch applied with Patrice's review tag.

Yours,
Linus Walleij

2019-04-23 10:37:24

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/5] pinctrl: pistachio: fix leaked of_node references

On Fri, Apr 12, 2019 at 8:01 AM Wen Yang <[email protected]> wrote:

> The call to of_get_child_by_name returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/pinctrl-pistachio.c:1422:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1360, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: [email protected]
> Cc: [email protected]

Patch applied.

Yours,
Linus Walleij

2019-04-23 10:55:02

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 5/5] pinctrl: zte: fix leaked of_node references

On Fri, Apr 12, 2019 at 8:01 AM Wen Yang <[email protected]> wrote:

> The call to of_parse_phandle returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
>
> Detected by coccinelle with the following warnings:
> ./drivers/pinctrl/zte/pinctrl-zx.c:415:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:422:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:436:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:444:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
> ./drivers/pinctrl/zte/pinctrl-zx.c:448:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
>
> Signed-off-by: Wen Yang <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Jun Nie <[email protected]>
> Cc: Shawn Guo <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: [email protected]
> Cc: [email protected]

Patch applied with Shawn's ACK.

Yours,
Linus Walleij