linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] add missing of_node_put after of_device_is_available
@ 2019-02-23 13:20 Julia Lawall
  2019-02-23 13:20 ` [PATCH 03/12] PowerPC-83xx: " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2019-02-23 13:20 UTC (permalink / raw)
  To: linux-amlogic
  Cc: linux-fbdev, linux-pm, kernel-janitors, linux-kernel, dri-devel,
	linux-crypto, linux-tegra, linux-omap, linuxppc-dev,
	linux-arm-kernel

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(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 03/12] PowerPC-83xx: add missing of_node_put after of_device_is_available
  2019-02-23 13:20 [PATCH 00/12] add missing of_node_put after of_device_is_available Julia Lawall
@ 2019-02-23 13:20 ` Julia Lawall
  2019-04-01 12:49   ` Mukesh Ojha
  2019-04-14 15:25   ` Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2019-02-23 13:20 UTC (permalink / raw)
  To: Scott Wood; +Cc: kernel-janitors, linux-kernel, Paul Mackerras, linuxppc-dev

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 <Julia.Lawall@lip6.fr>

---
 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"))) {


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 03/12] PowerPC-83xx: add missing of_node_put after of_device_is_available
  2019-02-23 13:20 ` [PATCH 03/12] PowerPC-83xx: " Julia Lawall
@ 2019-04-01 12:49   ` Mukesh Ojha
  2019-04-14 15:25   ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Mukesh Ojha @ 2019-04-01 12:49 UTC (permalink / raw)
  To: Julia Lawall, Scott Wood
  Cc: kernel-janitors, linux-kernel, Paul Mackerras, linuxppc-dev


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 <Julia.Lawall@lip6.fr>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

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"))) {
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 03/12] PowerPC-83xx: add missing of_node_put after of_device_is_available
  2019-02-23 13:20 ` [PATCH 03/12] PowerPC-83xx: " Julia Lawall
  2019-04-01 12:49   ` Mukesh Ojha
@ 2019-04-14 15:25   ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2019-04-14 15:25 UTC (permalink / raw)
  To: Julia Lawall, Mukesh Ojha, Scott Wood, linuxppc-dev
  Cc: kernel-janitors, linux-kernel, Paul Mackerras

> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-14 15:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23 13:20 [PATCH 00/12] add missing of_node_put after of_device_is_available Julia Lawall
2019-02-23 13:20 ` [PATCH 03/12] PowerPC-83xx: " Julia Lawall
2019-04-01 12:49   ` Mukesh Ojha
2019-04-14 15:25   ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).