[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240825-reset-cleanup-scoped-v1-1-03f6d834f8c0@linaro.org>
Date: Sun, 25 Aug 2024 16:14:24 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Philipp Zabel <p.zabel@...gutronix.de>,
Antoine Tenart <atenart@...nel.org>,
Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
Damien Le Moal <dlemoal@...nel.org>,
Palmer Dabbelt <palmerdabbelt@...gle.com>,
Vladimir Zapolskiy <vz@...ia.com>
Cc: linux-kernel@...r.kernel.org, Damien Le Moal <damien.lemoal@....com>,
linux-riscv@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: [PATCH 1/5] reset: berlin: fix OF node leak in probe() error path
Driver is leaking OF node reference on memory allocation failure.
Acquire the OF node reference after memory allocation to fix this and
keep it simple.
Fixes: aed6f3cadc86 ("reset: berlin: convert to a platform driver")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
---
drivers/reset/reset-berlin.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c
index 2537ec05ecee..578fe867080c 100644
--- a/drivers/reset/reset-berlin.c
+++ b/drivers/reset/reset-berlin.c
@@ -68,13 +68,14 @@ static int berlin_reset_xlate(struct reset_controller_dev *rcdev,
static int berlin2_reset_probe(struct platform_device *pdev)
{
- struct device_node *parent_np = of_get_parent(pdev->dev.of_node);
+ struct device_node *parent_np;
struct berlin_reset_priv *priv;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
+ parent_np = of_get_parent(pdev->dev.of_node);
priv->regmap = syscon_node_to_regmap(parent_np);
of_node_put(parent_np);
if (IS_ERR(priv->regmap))
--
2.43.0
Powered by blists - more mailing lists