linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] reset: berlin: Put parent device node on error path
@ 2021-01-21 15:11 Pan Bian
  2021-01-21 15:31 ` Antoine Tenart
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2021-01-21 15:11 UTC (permalink / raw)
  To: Philipp Zabel, Antoine Tenart, Sebastian Hesselbarth
  Cc: linux-kernel, Pan Bian

Put parent device node parent_np if there is no enough memory.

Fixes: aed6f3cadc86 ("reset: berlin: convert to a platform driver")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/reset/reset-berlin.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c
index 371197bbd055..cae58e40f639 100644
--- a/drivers/reset/reset-berlin.c
+++ b/drivers/reset/reset-berlin.c
@@ -72,8 +72,10 @@ static int berlin2_reset_probe(struct platform_device *pdev)
 	struct berlin_reset_priv *priv;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
+	if (!priv) {
+		of_node_put(parent_np);
 		return -ENOMEM;
+	}
 
 	priv->regmap = syscon_node_to_regmap(parent_np);
 	of_node_put(parent_np);
-- 
2.17.1


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

* Re: [PATCH] reset: berlin: Put parent device node on error path
  2021-01-21 15:11 [PATCH] reset: berlin: Put parent device node on error path Pan Bian
@ 2021-01-21 15:31 ` Antoine Tenart
  0 siblings, 0 replies; 2+ messages in thread
From: Antoine Tenart @ 2021-01-21 15:31 UTC (permalink / raw)
  To: Pan Bian, Philipp Zabel, Sebastian Hesselbarth; +Cc: linux-kernel, Pan Bian

Hello,

Quoting Pan Bian (2021-01-21 16:11:26)
> Put parent device node parent_np if there is no enough memory.
> 
> Fixes: aed6f3cadc86 ("reset: berlin: convert to a platform driver")
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  drivers/reset/reset-berlin.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c
> index 371197bbd055..cae58e40f639 100644
> --- a/drivers/reset/reset-berlin.c
> +++ b/drivers/reset/reset-berlin.c
> @@ -72,8 +72,10 @@ static int berlin2_reset_probe(struct platform_device *pdev)
>         struct berlin_reset_priv *priv;
>  
>         priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> -       if (!priv)
> +       if (!priv) {
> +               of_node_put(parent_np);
>                 return -ENOMEM;
> +       }

You could also move the of_get_parent() call here, to avoid having to
handle parent_np in an error path. That would improve maintainability
imho.

Thanks,
Antoine

>         priv->regmap = syscon_node_to_regmap(parent_np);
>         of_node_put(parent_np);

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

end of thread, other threads:[~2021-01-21 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 15:11 [PATCH] reset: berlin: Put parent device node on error path Pan Bian
2021-01-21 15:31 ` Antoine Tenart

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