linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] counter: stm32-timer-cnt: fix device_node handling in probe_encoder()
@ 2024-10-27 12:26 Javier Carrasco
  2024-11-01  5:59 ` William Breathitt Gray
  0 siblings, 1 reply; 2+ messages in thread
From: Javier Carrasco @ 2024-10-27 12:26 UTC (permalink / raw)
  To: Fabrice Gasnier, William Breathitt Gray, Maxime Coquelin,
	Alexandre Torgue
  Cc: William Breathitt Gray, linux-iio, linux-stm32, linux-arm-kernel,
	linux-kernel, stable, Javier Carrasco

Device nodes accessed via of_get_compatible_child() require
of_node_put() to be called when the node is no longer required to avoid
leaving a reference to the node behind, leaking the resource.

In this case, the usage of 'tnode' is straightforward and there are no
error paths, allowing for a single of_node_put() when 'tnode' is no
longer required.

Cc: stable@vger.kernel.org
Fixes: 29646ee33cc3 ("counter: stm32-timer-cnt: add checks on quadrature encoder capability")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/counter/stm32-timer-cnt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c
index 186e73d6ccb4..0d8206adccb3 100644
--- a/drivers/counter/stm32-timer-cnt.c
+++ b/drivers/counter/stm32-timer-cnt.c
@@ -694,6 +694,7 @@ static int stm32_timer_cnt_probe_encoder(struct device *dev,
 	}
 
 	ret = of_property_read_u32(tnode, "reg", &idx);
+	of_node_put(tnode);
 	if (ret) {
 		dev_err(dev, "Can't get index (%d)\n", ret);
 		return ret;

---
base-commit: a39230ecf6b3057f5897bc4744a790070cfbe7a8
change-id: 20241027-stm32-timer-cnt-of_node_put-8c6695e7a373

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>



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

* Re: [PATCH] counter: stm32-timer-cnt: fix device_node handling in probe_encoder()
  2024-10-27 12:26 [PATCH] counter: stm32-timer-cnt: fix device_node handling in probe_encoder() Javier Carrasco
@ 2024-11-01  5:59 ` William Breathitt Gray
  0 siblings, 0 replies; 2+ messages in thread
From: William Breathitt Gray @ 2024-11-01  5:59 UTC (permalink / raw)
  To: Fabrice Gasnier, Maxime Coquelin, Alexandre Torgue,
	Javier Carrasco
  Cc: William Breathitt Gray, William Breathitt Gray, linux-iio,
	linux-stm32, linux-arm-kernel, linux-kernel, stable


On Sun, 27 Oct 2024 13:26:49 +0100, Javier Carrasco wrote:
> Device nodes accessed via of_get_compatible_child() require
> of_node_put() to be called when the node is no longer required to avoid
> leaving a reference to the node behind, leaking the resource.
> 
> In this case, the usage of 'tnode' is straightforward and there are no
> error paths, allowing for a single of_node_put() when 'tnode' is no
> longer required.
> 
> [...]

Applied, thanks!

[1/1] counter: stm32-timer-cnt: fix device_node handling in probe_encoder()
      commit: 147359e23e5c9652ff8c5a98a51a7323bd51c94a

Best regards,
-- 
William Breathitt Gray <wbg@kernel.org>


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

end of thread, other threads:[~2024-11-01  6:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-27 12:26 [PATCH] counter: stm32-timer-cnt: fix device_node handling in probe_encoder() Javier Carrasco
2024-11-01  5:59 ` William Breathitt Gray

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