2019-02-23 14:02:06

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 00/12] add missing of_node_put after of_device_is_available

Failure of of_device_is_available implies that the device node
should be put, if it is not used otherwise.

---

arch/arm/mach-omap2/display.c | 4 +++-
arch/powerpc/platforms/83xx/usb.c | 4 +++-
drivers/bus/arm-cci.c | 4 +++-
drivers/cpufreq/armada-8k-cpufreq.c | 4 +++-
drivers/crypto/amcc/crypto4xx_trng.c | 4 +++-
drivers/firmware/psci.c | 4 +++-
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 4 +++-
drivers/gpu/drm/tegra/rgb.c | 4 +++-
drivers/phy/tegra/xusb.c | 4 +++-
drivers/soc/amlogic/meson-gx-socinfo.c | 4 +++-
drivers/tee/optee/core.c | 4 +++-
drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 4 +++-
12 files changed, 36 insertions(+), 12 deletions(-)


2019-02-23 13:59:27

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 01/12] arm-cci: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: 896ddd600ba4 ("drivers: bus: check cci device tree node status")
Signed-off-by: Julia Lawall <[email protected]>

---
This file doesn't seem to have a maintainer.

drivers/bus/arm-cci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -538,8 +538,10 @@ static int cci_probe(void)
struct resource res;

np = of_find_matching_node(NULL, arm_cci_matches);
- if (!of_device_is_available(np))
+ if (!of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }

ret = of_address_to_resource(np, 0, &res);
if (!ret) {


2019-02-23 13:59:29

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 03/12] PowerPC-83xx: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: c026c98739c7e ("powerpc/83xx: Do not configure or probe disabled FSL DR USB controllers")
Signed-off-by: Julia Lawall <[email protected]>

---
arch/powerpc/platforms/83xx/usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -221,8 +221,10 @@ int mpc837x_usb_cfg(void)
int ret = 0;

np = of_find_compatible_node(NULL, NULL, "fsl-usb2-dr");
- if (!np || !of_device_is_available(np))
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }
prop = of_get_property(np, "phy_type", NULL);

if (!prop || (strcmp(prop, "ulpi") && strcmp(prop, "serial"))) {


2019-02-23 13:59:32

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 07/12] drm: omapdrm: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: f2dd36ac9974c ("OMAPDSS: move 'compatible' converter to omapdss driver")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
@@ -192,8 +192,10 @@ static int __init omapdss_boot_init(void

dss = of_find_matching_node(NULL, omapdss_of_match);

- if (dss == NULL || !of_device_is_available(dss))
+ if (dss == NULL || !of_device_is_available(dss)) {
+ of_node_put(dss);
return 0;
+ }

omapdss_walk_device(dss, true);



2019-02-23 13:59:39

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 08/12] crypto: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: 5343e674f32fb ("crypto4xx: integrate ppc4xx-rng into crypto4xx")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/crypto/amcc/crypto4xx_trng.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
--- a/drivers/crypto/amcc/crypto4xx_trng.c
+++ b/drivers/crypto/amcc/crypto4xx_trng.c
@@ -80,8 +80,10 @@ void ppc4xx_trng_probe(struct crypto4xx_

/* Find the TRNG device node and map it */
trng = of_find_matching_node(NULL, ppc4xx_trng_match);
- if (!trng || !of_device_is_available(trng))
+ if (!trng || !of_device_is_available(trng)) {
+ of_node_put(trng);
return;
+ }

dev->trng_base = of_iomap(trng, 0);
of_node_put(trng);


2019-02-23 13:59:43

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 06/12] omapfb: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: f76ee892a99e6 ("omapfb: copy omapdss & displays for omapfb")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
--- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
@@ -193,8 +193,10 @@ static int __init omapdss_boot_init(void

dss = of_find_matching_node(NULL, omapdss_of_match);

- if (dss == NULL || !of_device_is_available(dss))
+ if (dss == NULL || !of_device_is_available(dss)) {
+ of_node_put(dss);
return 0;
+ }

omapdss_walk_device(dss, true);



2019-02-23 13:59:47

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 05/12] tee: optee: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: db878f76b9ff ("tee: optee: take DT status property into account")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/tee/optee/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -703,8 +703,10 @@ static int __init optee_driver_init(void
return -ENODEV;

np = of_find_matching_node(fw_np, optee_match);
- if (!np || !of_device_is_available(np))
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }

optee = optee_probe(np);
of_node_put(np);


2019-02-23 13:59:58

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 12/12] drivers: firmware: psci: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: d09a0011ec0d5 ("drivers: psci: Allow PSCI node to be disabled")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/firmware/psci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/firmware/psci.c b/drivers/firmware/psci.c
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -677,8 +677,10 @@ int __init psci_dt_init(void)

np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np);

- if (!np || !of_device_is_available(np))
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }

init_fn = (psci_initcall_t)matched_np->data;
return init_fn(np);


2019-02-23 14:00:31

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 10/12] cpufreq: ap806: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: f525a670533d9 ("cpufreq: ap806: add cpufreq driver for Armada 8K")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/cpufreq/armada-8k-cpufreq.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/cpufreq/armada-8k-cpufreq.c b/drivers/cpufreq/armada-8k-cpufreq.c
--- a/drivers/cpufreq/armada-8k-cpufreq.c
+++ b/drivers/cpufreq/armada-8k-cpufreq.c
@@ -128,8 +128,10 @@ static int __init armada_8k_cpufreq_init
struct cpumask cpus;

node = of_find_compatible_node(NULL, NULL, "marvell,ap806-cpu-clock");
- if (!node || !of_device_is_available(node))
+ if (!node || !of_device_is_available(node)) {
+ of_node_put(node);
return -ENODEV;
+ }

nb_cpus = num_possible_cpus();
freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);


2019-02-23 14:01:24

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 09/12] meson-gx-socinfo: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: a9daaba2965e8 ("soc: Add Amlogic SoC Information driver")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/soc/amlogic/meson-gx-socinfo.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/soc/amlogic/meson-gx-socinfo.c b/drivers/soc/amlogic/meson-gx-socinfo.c
--- a/drivers/soc/amlogic/meson-gx-socinfo.c
+++ b/drivers/soc/amlogic/meson-gx-socinfo.c
@@ -123,8 +123,10 @@ static int __init meson_gx_socinfo_init(
return -ENODEV;

/* check if interface is enabled */
- if (!of_device_is_available(np))
+ if (!of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }

/* check if chip-id is available */
if (!of_property_read_bool(np, "amlogic,has-chip-id"))


2019-02-23 14:01:25

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 11/12] ARM: OMAP2+: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")
Signed-off-by: Julia Lawall <[email protected]>

---
arch/arm/mach-omap2/display.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -250,8 +250,10 @@ static int __init omapdss_init_of(void)
if (!node)
return 0;

- if (!of_device_is_available(node))
+ if (!of_device_is_available(node)) {
+ of_node_put(node);
return 0;
+ }

pdev = of_find_device_by_node(node);



2019-02-23 14:01:56

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 04/12] phy: tegra: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: 53d2a715c2403 ("phy: Add Tegra XUSB pad controller support")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/phy/tegra/xusb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -260,8 +260,10 @@ tegra_xusb_pad_create(struct tegra_xusb_
int err;

np = tegra_xusb_find_pad_node(padctl, soc->name);
- if (!np || !of_device_is_available(np))
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
return NULL;
+ }

pad = soc->ops->probe(padctl, soc, np);
if (IS_ERR(pad)) {


2019-02-23 14:02:00

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 02/12] drm/tegra: rgb: add missing of_node_put after of_device_is_available

Add an of_node_put when a tested device node is not available.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
identifier f;
local idexpression e;
expression x;
@@

e = f(...);
... when != of_node_put(e)
when != x = e
when != e = x
when any
if (<+...of_device_is_available(e)...+>) {
... when != of_node_put(e)
(
return e;
|
+ of_node_put(e);
return ...;
)
}
// </smpl>

Fixes: d8f4a9eda0067 ("drm: Add NVIDIA Tegra20 support")
Signed-off-by: Julia Lawall <[email protected]>

---
drivers/gpu/drm/tegra/rgb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -u -p a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -221,8 +221,10 @@ int tegra_dc_rgb_probe(struct tegra_dc *
int err;

np = of_get_child_by_name(dc->dev->of_node, "rgb");
- if (!np || !of_device_is_available(np))
+ if (!np || !of_device_is_available(np)) {
+ of_node_put(np);
return -ENODEV;
+ }

rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);
if (!rgb)


2019-02-25 04:30:28

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH 10/12] cpufreq: ap806: add missing of_node_put after of_device_is_available

On 23-02-19, 14:20, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: f525a670533d9 ("cpufreq: ap806: add cpufreq driver for Armada 8K")
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/cpufreq/armada-8k-cpufreq.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/cpufreq/armada-8k-cpufreq.c b/drivers/cpufreq/armada-8k-cpufreq.c
> --- a/drivers/cpufreq/armada-8k-cpufreq.c
> +++ b/drivers/cpufreq/armada-8k-cpufreq.c
> @@ -128,8 +128,10 @@ static int __init armada_8k_cpufreq_init
> struct cpumask cpus;
>
> node = of_find_compatible_node(NULL, NULL, "marvell,ap806-cpu-clock");
> - if (!node || !of_device_is_available(node))
> + if (!node || !of_device_is_available(node)) {
> + of_node_put(node);
> return -ENODEV;
> + }
>
> nb_cpus = num_possible_cpus();
> freq_tables = kcalloc(nb_cpus, sizeof(*freq_tables), GFP_KERNEL);

Applied. Thanks.

--
viresh

2019-02-28 06:40:04

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 08/12] crypto: add missing of_node_put after of_device_is_available

On Sat, Feb 23, 2019 at 02:20:39PM +0100, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: 5343e674f32fb ("crypto4xx: integrate ppc4xx-rng into crypto4xx")
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/crypto/amcc/crypto4xx_trng.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2019-02-28 12:16:08

by Jens Wiklander

[permalink] [raw]
Subject: Re: [PATCH 05/12] tee: optee: add missing of_node_put after of_device_is_available

Hi Julia,
On Sat, Feb 23, 2019 at 2:58 PM Julia Lawall <[email protected]> wrote:
>
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: db878f76b9ff ("tee: optee: take DT status property into account")
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/tee/optee/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -703,8 +703,10 @@ static int __init optee_driver_init(void
> return -ENODEV;
>
> np = of_find_matching_node(fw_np, optee_match);
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> optee = optee_probe(np);
> of_node_put(np);
>

Applied.

Thanks,
Jens

2019-03-12 20:29:30

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH 09/12] meson-gx-socinfo: add missing of_node_put after of_device_is_available

Julia Lawall <[email protected]> writes:

> Add an of_node_put when a tested device node is not available.

[...]
]

> Fixes: a9daaba2965e8 ("soc: Add Amlogic SoC Information driver")
> Signed-off-by: Julia Lawall <[email protected]>

Patch applied,

Thanks,

Kevin

2019-03-22 22:26:10

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 11/12] ARM: OMAP2+: add missing of_node_put after of_device_is_available

* Julia Lawall <[email protected]> [190223 13:58]:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")
> Signed-off-by: Julia Lawall <[email protected]>

Thanks applying this one into omap-for-v5.1/fixes.

Regards,

Tony

Subject: Re: [PATCH 06/12] omapfb: add missing of_node_put after of_device_is_available


On 02/23/2019 02:20 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: f76ee892a99e6 ("omapfb: copy omapdss & displays for omapfb")
> Signed-off-by: Julia Lawall <[email protected]>

Patch queued for v5.2, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

2019-04-01 12:48:05

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 12/12] drivers: firmware: psci: add missing of_node_put after of_device_is_available


On 2/23/2019 6:50 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://Reviewed-by: Mukesh Ojha <[email protected]>
>
> Cheers,
> -Mukesh.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: d09a0011ec0d5 ("drivers: psci: Allow PSCI node to be disabled")
> Signed-off-by: Julia Lawall <[email protected]>
Reviewed-by: Mukesh Ojha <[email protected]>

Cheers,
-Mukesh
>
> ---
> drivers/firmware/psci.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -677,8 +677,10 @@ int __init psci_dt_init(void)
>
> np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np);
>
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> init_fn = (psci_initcall_t)matched_np->data;
> return init_fn(np);
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2019-04-01 12:49:39

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 01/12] arm-cci: add missing of_node_put after of_device_is_available


On 2/23/2019 6:50 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: 896ddd600ba4 ("drivers: bus: check cci device tree node status")
> Signed-off-by: Julia Lawall <[email protected]>


Reviewed-by: Mukesh Ojha <[email protected]>

Cheers,
-Mukesh

>
> ---
> This file doesn't seem to have a maintainer.
>
> drivers/bus/arm-cci.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -538,8 +538,10 @@ static int cci_probe(void)
> struct resource res;
>
> np = of_find_matching_node(NULL, arm_cci_matches);
> - if (!of_device_is_available(np))
> + if (!of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> ret = of_address_to_resource(np, 0, &res);
> if (!ret) {
>

2019-04-01 12:50:39

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 02/12] drm/tegra: rgb: add missing of_node_put after of_device_is_available


On 2/23/2019 6:50 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: d8f4a9eda0067 ("drm: Add NVIDIA Tegra20 support")
> Signed-off-by: Julia Lawall <[email protected]>
Reviewed-by: Mukesh Ojha <[email protected]>

Cheers,
-Mukesh
>
> ---
> drivers/gpu/drm/tegra/rgb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
> --- a/drivers/gpu/drm/tegra/rgb.c
> +++ b/drivers/gpu/drm/tegra/rgb.c
> @@ -221,8 +221,10 @@ int tegra_dc_rgb_probe(struct tegra_dc *
> int err;
>
> np = of_get_child_by_name(dc->dev->of_node, "rgb");
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);
> if (!rgb)
>

2019-04-01 12:51:11

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 03/12] PowerPC-83xx: add missing of_node_put after of_device_is_available


On 2/23/2019 6:50 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: c026c98739c7e ("powerpc/83xx: Do not configure or probe disabled FSL DR USB controllers")
> Signed-off-by: Julia Lawall <[email protected]>
Reviewed-by: Mukesh Ojha <[email protected]>

Cheers,
-Mukesh
>
> ---
> arch/powerpc/platforms/83xx/usb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
> --- a/arch/powerpc/platforms/83xx/usb.c
> +++ b/arch/powerpc/platforms/83xx/usb.c
> @@ -221,8 +221,10 @@ int mpc837x_usb_cfg(void)
> int ret = 0;
>
> np = of_find_compatible_node(NULL, NULL, "fsl-usb2-dr");
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
> prop = of_get_property(np, "phy_type", NULL);
>
> if (!prop || (strcmp(prop, "ulpi") && strcmp(prop, "serial"))) {
>

2019-04-01 12:51:39

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 04/12] phy: tegra: add missing of_node_put after of_device_is_available


On 2/23/2019 6:50 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: 53d2a715c2403 ("phy: Add Tegra XUSB pad controller support")
> Signed-off-by: Julia Lawall <[email protected]>
Reviewed-by: Mukesh Ojha <[email protected]>

Cheers,
-Mukesh
>
> ---
> drivers/phy/tegra/xusb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -260,8 +260,10 @@ tegra_xusb_pad_create(struct tegra_xusb_
> int err;
>
> np = tegra_xusb_find_pad_node(padctl, soc->name);
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return NULL;
> + }
>
> pad = soc->ops->probe(padctl, soc, np);
> if (IS_ERR(pad)) {
>

2019-04-01 13:00:52

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [PATCH 07/12] drm: omapdrm: add missing of_node_put after of_device_is_available


On 2/23/2019 6:50 PM, Julia Lawall wrote:
> Add an of_node_put when a tested device node is not available.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> identifier f;
> local idexpression e;
> expression x;
> @@
>
> e = f(...);
> ... when != of_node_put(e)
> when != x = e
> when != e = x
> when any
> if (<+...of_device_is_available(e)...+>) {
> ... when != of_node_put(e)
> (
> return e;
> |
> + of_node_put(e);
> return ...;
> )
> }
> // </smpl>
>
> Fixes: f2dd36ac9974c ("OMAPDSS: move 'compatible' converter to omapdss driver")
> Signed-off-by: Julia Lawall <[email protected]>


Reviewed-by: Mukesh Ojha <[email protected]>

Cheers,
-Mukesh

>
> ---
> drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff -u -p a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
> @@ -192,8 +192,10 @@ static int __init omapdss_boot_init(void
>
> dss = of_find_matching_node(NULL, omapdss_of_match);
>
> - if (dss == NULL || !of_device_is_available(dss))
> + if (dss == NULL || !of_device_is_available(dss)) {
> + of_node_put(dss);
> return 0;
> + }
>
> omapdss_walk_device(dss, true);
>
>

2019-04-14 14:46:45

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 01/12] arm-cci: add missing of_node_put after of_device_is_available

> @@ -538,8 +538,10 @@ static int cci_probe(void)
> struct resource res;
>
> np = of_find_matching_node(NULL, arm_cci_matches);
> - if (!of_device_is_available(np))
> + if (!of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> ret = of_address_to_resource(np, 0, &res);
> if (!ret) {

How do you think about to move this function call to an additional jump target
for the desired exception handling?

Regards,
Markus

2019-04-14 15:02:34

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 02/12] drm/tegra: rgb: add missing of_node_put after of_device_is_available

> @@ -221,8 +221,10 @@ int tegra_dc_rgb_probe(struct tegra_dc *
> int err;
>
> np = of_get_child_by_name(dc->dev->of_node, "rgb");
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);
> if (!rgb)

How do you think about to move this function call to an additional jump target
for the desired exception handling?

Regards,
Markus

2019-04-14 15:29:45

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 03/12] PowerPC-83xx: add missing of_node_put after of_device_is_available

> @@ -221,8 +221,10 @@ int mpc837x_usb_cfg(void)
> int ret = 0;
>
> np = of_find_compatible_node(NULL, NULL, "fsl-usb2-dr");
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
> prop = of_get_property(np, "phy_type", NULL);
>
> if (!prop || (strcmp(prop, "ulpi") && strcmp(prop, "serial"))) {

How do you think about to adjust the exception handling in this function
implementation a bit more according to the Linux coding style?

Regards,
Markus

2019-04-14 15:43:17

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 04/12] phy: tegra: add missing of_node_put after of_device_is_available

> @@ -260,8 +260,10 @@ tegra_xusb_pad_create(struct tegra_xusb_
> int err;
>
> np = tegra_xusb_find_pad_node(padctl, soc->name);
> - if (!np || !of_device_is_available(np))
> + if (!np || !of_device_is_available(np)) {
> + of_node_put(np);
> return NULL;
> + }
>
> pad = soc->ops->probe(padctl, soc, np);
> if (IS_ERR(pad)) {

How do you think about to move this function call to an additional jump target
for the desired exception handling?

Regards,
Markus

2019-04-14 16:13:15

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 09/12] meson-gx-socinfo: add missing of_node_put after of_device_is_available

> @@ -123,8 +123,10 @@ static int __init meson_gx_socinfo_init(
> return -ENODEV;
>
> /* check if interface is enabled */
> - if (!of_device_is_available(np))
> + if (!of_device_is_available(np)) {
> + of_node_put(np);
> return -ENODEV;
> + }
>
> /* check if chip-id is available */
> if (!of_property_read_bool(np, "amlogic,has-chip-id"))

How do you think about to adjust the exception handling in this function
implementation a bit more according to the Linux coding style?

Regards,
Markus

2019-04-14 16:39:28

by Markus Elfring

[permalink] [raw]
Subject: Re: [11/12] ARM: OMAP2+: add missing of_node_put after of_device_is_available

> @@ -250,8 +250,10 @@ static int __init omapdss_init_of(void)
> if (!node)
> return 0;
>
> - if (!of_device_is_available(node))
> + if (!of_device_is_available(node)) {
> + of_node_put(node);
> return 0;
> + }
>
> pdev = of_find_device_by_node(node);

Is there a need to put the node also in subsequent if branches
for complete exception handling in this function implementation?

Regards,
Markus

2019-04-14 16:50:15

by Julia Lawall

[permalink] [raw]
Subject: Re: [11/12] ARM: OMAP2+: add missing of_node_put after of_device_is_available



On Sun, 14 Apr 2019, Markus Elfring wrote:

> > @@ -250,8 +250,10 @@ static int __init omapdss_init_of(void)
> > if (!node)
> > return 0;
> >
> > - if (!of_device_is_available(node))
> > + if (!of_device_is_available(node)) {
> > + of_node_put(node);
> > return 0;
> > + }
> >
> > pdev = of_find_device_by_node(node);
>
> Is there a need to put the node also in subsequent if branches
> for complete exception handling in this function implementation?

Yes, it looks like this is indeed missing. I will try to send a better
patch when time permits.

julia

2019-04-16 13:03:10

by Robin Murphy

[permalink] [raw]
Subject: Re: [PATCH 01/12] arm-cci: add missing of_node_put after of_device_is_available

On 14/04/2019 15:45, Markus Elfring wrote:
>> @@ -538,8 +538,10 @@ static int cci_probe(void)
>> struct resource res;
>>
>> np = of_find_matching_node(NULL, arm_cci_matches);
>> - if (!of_device_is_available(np))
>> + if (!of_device_is_available(np)) {
>> + of_node_put(np);
>> return -ENODEV;
>> + }
>>
>> ret = of_address_to_resource(np, 0, &res);
>> if (!ret) {
>
> How do you think about to move this function call to an additional jump target
> for the desired exception handling?

TBH it looks like the whole thing could do with a bit of refactoring -
strictly we should probably be dropping the node reference in all the
other failure paths too.

Robin.