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(-)
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) {
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"))) {
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);
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);
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);
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);
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);
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);
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"))
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);
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)) {
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)
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
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
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
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
* 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
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
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
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) {
>
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)
>
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"))) {
>
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)) {
>
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);
>
>
> @@ -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
> @@ -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
> @@ -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
> @@ -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
> @@ -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
> @@ -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
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
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.