public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()
@ 2024-09-24 18:08 Markus Elfring
  2024-09-25  7:46 ` AngeloGioacchino Del Regno
  2024-10-02  9:08 ` AngeloGioacchino Del Regno
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2024-09-24 18:08 UTC (permalink / raw)
  To: linux-mediatek, linux-arm-kernel, Angelo Gioacchino Del Regno,
	Kevin Hilman, Matthias Brugger, Roger Lu
  Cc: LKML, kernel-janitors, Krzysztof Kozlowski

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Sep 2024 20:00:09 +0200

An of_node_put(np) call was immediately used after a pointer check
for a of_find_device_by_node() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/soc/mediatek/mtk-svs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 9a91298c1253..7c349a94b45c 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -2133,14 +2133,12 @@ static struct device *svs_get_subsys_device(struct svs_platform *svsp,
 	}

 	pdev = of_find_device_by_node(np);
+	of_node_put(np);
 	if (!pdev) {
-		of_node_put(np);
 		dev_err(svsp->dev, "cannot find pdev by %s\n", node_name);
 		return ERR_PTR(-ENXIO);
 	}

-	of_node_put(np);
-
 	return &pdev->dev;
 }

--
2.46.1


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

* Re: [PATCH] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()
  2024-09-24 18:08 [PATCH] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device() Markus Elfring
@ 2024-09-25  7:46 ` AngeloGioacchino Del Regno
  2024-10-02  9:08 ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-09-25  7:46 UTC (permalink / raw)
  To: Markus Elfring, linux-mediatek, linux-arm-kernel, Kevin Hilman,
	Matthias Brugger, Roger Lu
  Cc: LKML, kernel-janitors, Krzysztof Kozlowski

Il 24/09/24 20:08, Markus Elfring ha scritto:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 24 Sep 2024 20:00:09 +0200
> 
> An of_node_put(np) call was immediately used after a pointer check
> for a of_find_device_by_node() call in this function implementation.
> Thus call such a function only once instead directly before the check.
> 
> This issue was transformed by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> ---
>   drivers/soc/mediatek/mtk-svs.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
> index 9a91298c1253..7c349a94b45c 100644
> --- a/drivers/soc/mediatek/mtk-svs.c
> +++ b/drivers/soc/mediatek/mtk-svs.c
> @@ -2133,14 +2133,12 @@ static struct device *svs_get_subsys_device(struct svs_platform *svsp,
>   	}
> 
>   	pdev = of_find_device_by_node(np);
> +	of_node_put(np);
>   	if (!pdev) {
> -		of_node_put(np);
>   		dev_err(svsp->dev, "cannot find pdev by %s\n", node_name);
>   		return ERR_PTR(-ENXIO);
>   	}
> 
> -	of_node_put(np);
> -
>   	return &pdev->dev;
>   }
> 
> --
> 2.46.1
> 


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

* Re: [PATCH] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()
  2024-09-24 18:08 [PATCH] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device() Markus Elfring
  2024-09-25  7:46 ` AngeloGioacchino Del Regno
@ 2024-10-02  9:08 ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-10-02  9:08 UTC (permalink / raw)
  To: linux-mediatek, linux-arm-kernel, Kevin Hilman, Matthias Brugger,
	Roger Lu, Markus Elfring
  Cc: LKML, kernel-janitors, Krzysztof Kozlowski

On Tue, 24 Sep 2024 20:08:15 +0200, Markus Elfring wrote:
> An of_node_put(np) call was immediately used after a pointer check
> for a of_find_device_by_node() call in this function implementation.
> Thus call such a function only once instead directly before the check.
> 
> This issue was transformed by using the Coccinelle software.
> 
> 
> [...]

Applied to v6.12-next/soc, thanks!

[1/1] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()
      https://git.kernel.org/mediatek/c/1ee71494

Cheers,
Angelo



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

end of thread, other threads:[~2024-10-02  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24 18:08 [PATCH] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device() Markus Elfring
2024-09-25  7:46 ` AngeloGioacchino Del Regno
2024-10-02  9:08 ` AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox