diff mbox series

soc: samsung: Add missing of_node_put in exynos-pmu.c

Message ID 20220615085525.3961330-1-windhl@126.com (mailing list archive)
State New
Headers show
Series soc: samsung: Add missing of_node_put in exynos-pmu.c | expand

Commit Message

Liang He June 15, 2022, 8:55 a.m. UTC
In exynos_get_pmu_regmap(), of_find_matching_node() will return a
node pointer with refcount incremented. We should use of_node_put()
for that node pointer. We need a similar code logic in the function
syscon_regmap_lookup_by_compatible().

Signed-off-by: heliang <windhl@126.com>
---
 drivers/soc/samsung/exynos-pmu.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Krzysztof Kozlowski June 15, 2022, 1:45 p.m. UTC | #1
On 15/06/2022 01:55, heliang wrote:
> In exynos_get_pmu_regmap(), of_find_matching_node() will return a
> node pointer with refcount incremented. We should use of_node_put()
> for that node pointer. We need a similar code logic in the function
> syscon_regmap_lookup_by_compatible().
> 
> Signed-off-by: heliang <windhl@126.com>

Please use full first and last name. It might be that transcription of
your name to Latin alphabet looks a bit different.

> ---
>  drivers/soc/samsung/exynos-pmu.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
> index 732c86ce2be8..a44862c405a4 100644
> --- a/drivers/soc/samsung/exynos-pmu.c
> +++ b/drivers/soc/samsung/exynos-pmu.c
> @@ -108,9 +108,13 @@ struct regmap *exynos_get_pmu_regmap(void)
>  {
>  	struct device_node *np = of_find_matching_node(NULL,
>  						      exynos_pmu_of_device_ids);
> -	if (np)
> -		return syscon_node_to_regmap(np);
> -	return ERR_PTR(-ENODEV);
> +	struct regmap *regmap;

Blank line here.

> +	if (!np)
> +		return ERR_PTR(-ENODEV);
> +	
> +	regmap = syscon_node_to_regmap(np);
> +	of_node_put(np);
> +	return regmap;
>  }
>  EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap);
>  


Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
index 732c86ce2be8..a44862c405a4 100644
--- a/drivers/soc/samsung/exynos-pmu.c
+++ b/drivers/soc/samsung/exynos-pmu.c
@@ -108,9 +108,13 @@  struct regmap *exynos_get_pmu_regmap(void)
 {
 	struct device_node *np = of_find_matching_node(NULL,
 						      exynos_pmu_of_device_ids);
-	if (np)
-		return syscon_node_to_regmap(np);
-	return ERR_PTR(-ENODEV);
+	struct regmap *regmap;
+	if (!np)
+		return ERR_PTR(-ENODEV);
+	
+	regmap = syscon_node_to_regmap(np);
+	of_node_put(np);
+	return regmap;
 }
 EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap);