linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()'
@ 2021-04-20 19:31 Christophe JAILLET
  2021-04-21  8:43 ` Charles Keepax
  2021-04-21 19:03 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-04-20 19:31 UTC (permalink / raw)
  To: lgirdwood, broonie, ckeepax
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

'for_each_available_child_of_node()' already performs an 'of_node_get()'
on child, so there is no need to perform another one before returning.
Otherwise, a double 'get' is performed and a resource may never be
released.

Fixes: 925c85e21ed8 ("regulator: Factor out location of init data OF node")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Untested, speculative patch
---
 drivers/regulator/of_regulator.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 564f928eb1db..49f6c05fee34 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -422,7 +422,11 @@ device_node *regulator_of_get_init_node(struct device *dev,
 
 		if (!strcmp(desc->of_match, name)) {
 			of_node_put(search);
-			return of_node_get(child);
+			/*
+			 * 'of_node_get(child)' is already performed by the
+			 * for_each loop.
+			 */
+			return child;
 		}
 	}
 
-- 
2.27.0


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

* Re: [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()'
  2021-04-20 19:31 [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()' Christophe JAILLET
@ 2021-04-21  8:43 ` Charles Keepax
  2021-04-21 19:03 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2021-04-21  8:43 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: lgirdwood, broonie, linux-kernel, kernel-janitors

On Tue, Apr 20, 2021 at 09:31:51PM +0200, Christophe JAILLET wrote:
> 'for_each_available_child_of_node()' already performs an 'of_node_get()'
> on child, so there is no need to perform another one before returning.
> Otherwise, a double 'get' is performed and a resource may never be
> released.
> 
> Fixes: 925c85e21ed8 ("regulator: Factor out location of init data OF node")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

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

* Re: [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()'
  2021-04-20 19:31 [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()' Christophe JAILLET
  2021-04-21  8:43 ` Charles Keepax
@ 2021-04-21 19:03 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-04-21 19:03 UTC (permalink / raw)
  To: lgirdwood, ckeepax, Christophe JAILLET
  Cc: Mark Brown, linux-kernel, kernel-janitors

On Tue, 20 Apr 2021 21:31:51 +0200, Christophe JAILLET wrote:
> 'for_each_available_child_of_node()' already performs an 'of_node_get()'
> on child, so there is no need to perform another one before returning.
> Otherwise, a double 'get' is performed and a resource may never be
> released.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()'
      commit: 8a065ce92b218e453742b745162d75a6f86fb768

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2021-04-21 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 19:31 [PATCH] regulator: Avoid a double 'of_node_get' in 'regulator_of_get_init_node()' Christophe JAILLET
2021-04-21  8:43 ` Charles Keepax
2021-04-21 19:03 ` Mark Brown

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